<p>I am looking for a way to mount\unmount a USB flash drive using VBScript.  This is the closest I was able to get.</p>

<pre><code>Sub EjectDrive(strDrive)
On Error Resume Next
CONST SSF_DRIVES = 17
Set objShell = CreateObject("Shell.Application")
Set objDrive = objShell.Namespace(SSF_DRIVES).ParseName(strDrive)
objDrive.InvokeVerb "E&amp;ject"
End Sub
</code></pre>

This will work on Windows Server 2003, but not NT/2000/XP/Vista unfortunately.
```
```
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Volume Where Name = 'E:\\'")

For Each objItem in colItems
    objItem.Dismount(True, True)
Next
```
```
From
Dismount a Volume
.