,

Your IP Address

what is my ip address?

Ejecting USB drives from the command line

A client of mine requires me to use their hardware to link to their network, but I do my development on my own hardware. To keep things straight, I use a external USB hard drive to keep my local copy of their repository. Switching between the machines is kind of a pain, so anytime I can simplify the process, Im all for it.

Because Im running IIS and debugging through Visual Studio, Im not able to "Safely Remove Hardware" using the icon in the dock. IIS keeps a lock on the files on the drive which means I get "The device generic volume cannot be stopped right now. Try stopping the device later." error.

The quickest solution I could get was to perform a "iisreset /restart" from the command line, as well as then remove hardware.

Too lots of annoying steps.

I did some research on stopping an external device by the command line, as well as came across this Ask Leo post. Essentially, Microsoft provides a utility called devcon that lets you stop USB devices from the DOS prompt.

First I ran devcon status * to get out the name of my hard drive. It was something lengthy and nasty:

USBSTORDISK&VEN_WD*PROD_2500BEV_EXTERNAL&REV_1.04575843383037353439393539&O
Name: WD 2500BEV External USB Device
Driver is running.
If I run the following at the command line, it will stop the device (provided nothing else is preventing it from doing so:

devcon remove USBSTORDISK*

(The asterisk is a wildcard character and really is needed because the command line pukes on ampersands anyway.)

Being the occasionally smart fellow I am, I created a little batch file I want to call eject.bat:

iisreset /stop
devcon remove USBSTORDISK*
iisreset /start

Now, IIS is stopped, the drive ejected, as well as IIS started again. I just run it from the command line and Ive saved myself 13.8 seconds (+/- 20 seconds).

0 comments:

Post a Comment