Because you're dealing with remote objects, I'm thinking you might have
to add this line:
...
$objItem.Dismount($true,$true)
$objItem.Put() <--Add this
...
**Not tested**
Marco
If I change the second parameter to false, the dismount succeeds - not that
I can tell what that means, since it is still visible in Explorer. However,
the returned result code is a 0. Possibly this is because I'm using a drive
letter assigned USB drive to test this against. This is also a local test as
you can tell, so it doesn't precisely mimic what you did.
Here's the PowerShell version, working against drive K:
get-wmiobject -Class Win32_Volume | where{$_.name -eq 'K:\'} |
%{$_.Dismount($true,$false)}
Here's the VBScript version:
Set volumes = GetObject("winmgmts://./root/cimv2")._
ExecQuery("Select * from Win32_Volume")
For Each volume in volumes
if volume.Name = "K:\" Then
result = volume.Dismount(true, false)
WScript.Echo result
end if
next
"CodeTestDummy" <sharp_mind....@email.TAKETHISOUT.msn.comm> wrote in
message news:E66E0B26-83D1-4620...@microsoft.com...
$vol=get-wmiobject -Class Win32_Volume | where{$_.name -eq 'K:\'};
$vol.DriveLetter = $null;
$vol.Put();
$vol.DisMount($false, $false);
Alex
> On Tuesday, May 13, 2008 2:33 PM CodeTestDummy wrote:
> Why is not working? It works in the VBS.
>
> $colDrives = get-wmiobject -Class Win32_Volume -namespace
> "root\CIMV2" -computername $strComputer | where{$_.name -eq $strDrive}
>
> foreach($objItem in $colDrives)
> {
> $objItem.Dismount($True, $True)
>
> }
>> On Tuesday, May 13, 2008 2:59 PM Marco Shaw [MVP] wrote:
>> CodeTestDummy wrote:
>>
>> Because you're dealing with remote objects, I'm thinking you might have
>> to add this line:
>>
>> ...
>> $objItem.Dismount($true,$true)
>> $objItem.Put() <--Add this
>> ...
>>
>> **Not tested**
>>
>> Marco
>>> Submitted via EggHeadCafe
>>> JSONP AJAX and ASP.NET Demystified
>>> http://www.eggheadcafe.com/tutorials/aspnet/b71ea548-93e0-4cec-9fb1-35f641b83e65/jsonp-ajax-and-aspnet-demystified.aspx