![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Dismount drive 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) } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Dismount drive CodeTestDummy wrote: Quote: > 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) > > } to add this line: .... $objItem.Dismount($true,$true) $objItem.Put() <--Add this .... **Not tested** Marco |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Dismount drive I'm not able to make this work in either PowerShell or VBScript. It appears to work if executed, but the invocation always returns a result code of 2, which means that the volume has mount points. Below is my test VBScript code. It appears that the mount point has to be removed before the volume can be dismounted. 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.TAKETHISOUT@xxxxxx> wrote in message news:E66E0B26-83D1-4620-AF32-AB3AAF0FD1FC@xxxxxx Quote: > 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) > > } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Combo RAID1 and standard Drive setup problem - Unallocated Drive | General Discussion | |||
| Mount or Dismount a Drive or Partition to a Folder | Tutorials | |||
| Access XP data drive using Vista Ult (XP drive=slave drive only NO | Vista account administration | |||
| Vista on the C: drive but System drive is the D: drive - any way to | Vista installation & setup | |||
| Vista maping drive to server 2000 shared drive not recognize user/ | Vista networking & sharing | |||