How to? Hot dismount USB virtual disk

#1
One of my computers currently enjoys lack of NIC drivers. All transfers are done by USB disk emulators. I assume that both in WinXP and Win7 there are API calls (hopefully the same ones) to dismount the drive by TCC command so it can be safely removed. This would be more convenient that mouse manipulations.
 
#3
One of my computers currently enjoys lack of NIC drivers. All transfers are done by USB disk emulators. I assume that both in WinXP and Win7 there are API calls (hopefully the same ones) to dismount the drive by TCC command so it can be safely removed. This would be more convenient that mouse manipulations.
Code (2000/XP) for it here: http://support.microsoft.com/kb/165721

I'll try building an EXE later.

I suspect that just yanking it could lead to problems ... corruption possibly, orphaned open handles almost certainly. Stray open handles can cause delays at shutdown/logoff
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,724
47
Albuquerque, NM
prospero.unm.edu
#4
One of my computers currently enjoys lack of NIC drivers. All transfers are done by USB disk emulators. I assume that both in WinXP and Win7 there are API calls (hopefully the same ones) to dismount the drive by TCC command so it can be safely removed. This would be more convenient that mouse manipulations.
EJECTMEDIA ?
 
#6
***Just re-read after posting, that you want to remove USB virtual disk. My bad.

I use DEVCON for this. (Ref. http://jpsoft.com/forums/threads/enable-disable-wifi-from-command-line.4424/#post-28890 on what else I use DEVCON for).

Let's say that I want to disable my Lexar USB Flash Drive. From the command line;

Code:
devcon status usb*
This returns all usb devices on my system, which scrolls by on my screen. However, I do see my Lexar USB Flash Drive listed. So,

Code:
devcon status lexar*
This returns;

Code:
USBSTOR\DISK&VEN_LEXAR&PROD_USB_FLASH_DRIVE&REV_8.07\20130524035127250FE1&0
  Name: Lexar USB Flash Drive USB Device
  Driver is running.
1 matching device(s) found.
To disable this device, I do;

Code:
devcon disable lexar*
which returns;

Code:
USBSTOR\DISK&VEN_LEXAR&PROD_USB_FLASH_DRIVE&REV_8.07\20130524035127250FE1&0: Disabled on reboot
Not all of 1 device(s) disabled, at least one requires reboot to complete the operation.
Hmm...oh, I see, I have that drive opened in Windows Explorer. Let me close Windows Explorer. Try again;

Code:
USBSTOR\DISK&VEN_LEXAR&PROD_USB_FLASH_DRIVE&REV_8.07\20130524035127250FE1&0: Disabled
1 device(s) disabled.
That's better. I can now remove the drive. Actually, I don't want to, so I will just enable it;

Code:
devcon enable lexar*
which returns;

Code:
USBSTOR\DISK&VEN_LEXAR&PROD_USB_FLASH_DRIVE&REV_8.07\20130524035127250FE1&0: Enabled
1 device(s) enabled.
Joe
 
Last edited:
#7
Well, I started up a USB virtual disk, and found it as;

Code:
devcon status *vdisk*
which returned;

Code:
{CB107E6E-5323-489E-AD3C-907943A99D83}\VDISK\1&1AAFB3D5&0&01
  Name: Microsoft Virtual Server Storage Device01
  Driver is running.
1 matching device(s) found.
However, I could not disable it with devcon, even though I did not have it (drive V) open in Windows Explorer, or any other program.

Joe
 
#8
Appreciate the answers above, one could not ask for a more responsive community!

Code (2000/XP) for it here: http://support.microsoft.com/kb/165721
I'll try building an EXE later.
I suspect that just yanking it could lead to problems ... corruption possibly, orphaned open handles almost certainly. Stray open handles can cause delays at shutdown/logoff
Hope you do, because indeed yanking out a USB disk emulator can corrupt its file system. I tried fixing one - had to be reformatted...

My comments for the other answers below.

The internal command EJECTMEDIA has a warning: "It is not intended for unmounting USB drives."

Mount / dismount are operations not listed by WinNT, but show up when you want to chkdsk a drive. Obviously it can be done with a compiled program (eiher a plugin or a stand-alone one). I was hoping that somebody can inform me of an API one can invoke from TCC with the @WINAPI[] function to dismount the USB device. On rare occasions the mount function may also be desirable.

I wrote "disk emulator" because at least one of my devices has no physical disk drive (SD card). The driver makes it behave as if it were a disk drive, hence it is a virtual disk.

I do not have DEVCON, nor a compiler that's ready to use.
 
#13
Vince:
Your EJECT.EXE works fine but for external HDs. Renamed it for my own use DISMOUNT.
Nickles:
I tested Uwe Siebers version, and it worked line a charm! To my amazement when I asked it to remove just one of the three letters assigned to the drive, it found all 3 (including the one which is not accessible as a drive letter), prompted and removed the whole drive.