Is there a command line (or autohotkey) way of dismounting a USB drive?

4

I find dismounting a USB drive takes far too many mouse clicks for my liking. Is there are command line way of doing it (XP and Vista)?

Addition I have an eye condition that makes hand mouse coordination difficult so any suggestion that there aren't too many clicks will be downvoted as not answering my question.

However I use AutoHotkey a lot and one use case would be to call it from an AHK script. So if there is a way to code it in AHK that will do. Added this to the tags.

Further question - is it safe to remove a disk when the computer is a. on Standby or b. Hibernated. I recall that W2000 got uspet if you pulled a disk from a hibernated machine. Or is it better to explicitly dismount or sync before you hibernate or standby - prabably in a script.

justintime

Posted 2010-04-30T19:19:16.990

Reputation: 2 651

1Wayyyyyyyyyy too many clicks. – rodey – 2010-04-30T19:37:39.850

Only two clicks in KDE :P. – marcusw – 2010-04-30T19:54:15.770

fyi: There is no need to unmount drives that are in "Optimize for quick removal" mode (default for USB removable drives); in it, the cache is flushed every two seconds (IIRC). Only those which are set to "Optimize for performance" need to be unmounted. (On the second thought, this might not apply to NTFS pendrives...) – user1686 – 2010-05-02T17:58:21.240

Answers

8

USB Disk Ejector:

usbejector /removeletter g

sync from SysInternals:

sync -e g h

(Both of these only work with disks that have a letter assigned)

user1686

Posted 2010-04-30T19:19:16.990

Reputation: 283 655

3+1 for sync; IMO best option. – squircle – 2010-04-30T22:01:57.083

will give them both a try.... Will accept if they work for me (which I am sure they will). – justintime – 2010-05-01T18:44:14.073

1

DevEject

Usage: deveject -EjectDrive:<Drive>|-EjectName:<Name>|-EjectId:<DeviceId> [-v] [-Debug]

Example: deveject -EjectName:"USB Mass Storage Device"

Chris Mc

Posted 2010-04-30T19:19:16.990

Reputation: 31

1

You can use this simple script to make hotkey for quick ejecting disk .

; Eject USB

^+e:: Run "X:\Your\Path\To\sync.exe" -e [Your USB drive disks]

example:

; Eject USB

^+e:: Run "E:\Soft\SysinternalSuite\sync.exe" -e g h

And reload your autohotkey, press Ctrl+Shift+E :)

Dzung Nguyen

Posted 2010-04-30T19:19:16.990

Reputation: 1 351

1

Here's another free command line tool for removing USB drives:

RemoveDrive prepares drives for "Safe Removal" by commandline. It can let you run the command into a loop until it succeeds, and let Windows show the "Safe to Remove" balloon tip when it's done. (I'm using Console here if anyone's wondering.)

alt text

The software runs on Windows 2000, XP, or higher. It has 32- and 64-bit editions as well.


Personally, I would remove any USB drive before I let the machine sleep or hibernate, just to make sure all my data is safe inside the USB drive and there are no open file handles left.

Isxek

Posted 2010-04-30T19:19:16.990

Reputation: 3 785