Page 1 of 1

Usb drive remove botton

Posted: 2007-11-24, 14:27 UTC
by strategico
It would be nice if there was a command to unmount usb stick (so I can put a botton on the menu bar ...).
Better more if the fixed hd sata wasn't listed...

Greetings.

Posted: 2007-11-24, 18:59 UTC
by karlchen
Maybe not 100% of what you ask, yet, 90%, I guess. And it works fine here:

Title: Unload USB Device
Command:
RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
Drawback:
Clicking on this command (button), a dialogue will popup where I have to select which of the USB devices to de-activate. So I need two mouse clicks: select the right device, click on "Stop".

No SATA harddisks will be listed unless they are external and connected to an USB interface.

HTH,
Karl

Posted: 2007-11-24, 19:17 UTC
by djk
2karlchen
Thanks, really good solution.

Posted: 2007-11-24, 21:22 UTC
by karlchen
djk wrote:2karlchen
Thanks, really good solution.
As I do not wish to adorn myself with borrowed plumes, I will simply admit that I got the command line to call the "unplug USB devices" dialogue from some clever blog entry somewhere.
(Might even be that the same commandline has been posted inside this forum, too. ... yes, it has e.g. by Sombra here)

When reading through that thread again, the reference to a Nirsoft utility was redetected: USBDeview v1.11 .

With the help of USBDeview you cannot only list all USB devices. but you can also disconnect USB devices and even uninstall them.

Telling from the section "Stop/Disconnect Command-Line Options" it is indeed possible to disconnect a specified USB device using "USBDeview" commandline options, provided you know e.g. the USB stick name as displayed by "USBDeview" or the USB stick serial number. (Look up either of the two with the help of "USBDeview".)

This in turn suggests that strategico might be able to create a button and add the appropriate USBDeview commandline and it will disconnect the USB stick as expected.
(Have not tried this usage of USBDeview so far, have only used its GUI for viewing purposes.)

HTH,
Karl

Posted: 2007-11-25, 01:36 UTC
by karlchen
Hi, strategico. Hi, folks.

In the meantime, I have tested how well USBDeview can stop a USB stick so that it can be unplugged safely.

Good News:

It worked fine for both USB sticks which I plugged in 1 at a time and which I de-activated then with the help of a USBDeview commandline. :)

How to Proceed:

If you use the same USB stick all the time the procedure is pretty easy:
  • (1) plugin the stick
  • (2) launch USBDeview and get the exact device description as displayed by USBDeview. (The device name may be of little use in particular on recent machines where USB hubs are used.)
  • (3) Create a new TC button holding the commandline to unload this stick.
  • (4) the commandline will read:

    Code: Select all

    USBDeview /stop /showmsg "displayed device description"
  • (5) press the new button to unload the stick. If you did not commit a mistake, Windows will show a message that you may safely unplug the stick.
Bad News:

Different USB sticks will have different descriptions. As a consequence you will need one USBDeview commandline for each USB stick.

I.e. for my two USB sticks I ended up with the following two commandlines:

Code: Select all

usbdeview /stop /showmsg "@usbstor.inf,%genericbulkonly.devicedesc%;USB-Massenspeichergerät"
usbdeview /stop /showmsg "Generic STORAGE DEVICE USB Device"
(Go figure out which USB sticks I really used. :wink: )

Provided that you use a larger number of different USB sticks on your system, using the USBView commandline in order to unload them may be quite a hassle.
In such cases, using the the commandline given in a previous post

Code: Select all

RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
may be a more pragmatical approach.

Ciao,
Karl

Posted: 2007-12-27, 05:47 UTC
by kalokagathon
You don't really need to disconnect USB sticks with the remove hardware procedure or similar - they don't use the drive cache, so no need to disconnect - once finished with file operations and idle, they can be pulled right out.

To verify, put in a USB stick, right-click on its button -> properties -> hardware -> double-click its name in the list of drives -> choose policies tab: "Optimize for quick removal" is default for USB sticks - no need to go through a "disconnect" routine.

[I would have put an image (... a 1000 words...), but as I have no website, I can't...]

Posted: 2007-12-27, 10:31 UTC
by petermad
2kalokagathon
I would have put an image (... a 1000 words...), but as I have no website, I can't...
I have put one up for you - unfortunately only in Danish:

http://madsenworld.dk/tcmd/usb.png

I hope people can recognize it in their own languages.

Posted: 2007-12-30, 00:19 UTC
by Hacker
kalokagathon,
"Optimize for quick removal" is default for USB sticks
AFAIK this has been the default only since Windows XP.

Roman