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.

  • 1
    Wayyyyyyyyyy too many clicks.
    – rodey
    Apr 30 '10 at 19:37
  • Only two clicks in KDE :P.
    – marcusw
    Apr 30 '10 at 19:54
  • 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
    May 2 '10 at 17:58

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)

  • 3
    +1 for sync; IMO best option.
    – squircle
    Apr 30 '10 at 22:01
  • will give them both a try.... Will accept if they work for me (which I am sure they will).
    – justintime
    May 1 '10 at 18:44

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.


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]


; Eject USB

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

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



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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.