EjectUSB

EjectUSB
Version 1.6
Designed to be a simple utility to close all programs running from a specified drive or folder and then attempt ejection if a drive was specified. Extended functionality includes flushing the file cache, closing Explorer windows and removing registry entries and Recent Document shortcuts referencing the specified drive or folder.

Documentation and an example configuration file are included in the ZIP. The source code is available as a separate download.

TrueCrypt and combination flash card / flash drives support will be made available via configuration files after sufficient testing has been conducted.

See EjectUSB in action!
» Watch the flash video

Release Version 1.6:
» Download EjectUSB (259 kilobytes, 115270 downloads)
» Source Code (26 kilobytes, 9186 downloads)


Change Log:
Version 1.6
- Bug fix: EjectUSB no longer triggers file access errors on WinXP when run from read-only media when trying to load its hourglass tray icon.
- Bug fix: Sysinternals registry keys are no longer erroneously deleted.

Version 1.5 (161498 downloads)
- Bug fix: EjectUSB's ejection success message will more reliably appear on Vista.
- Bug fix: EjectUSB's ejection success message will only disappear when the ejected drive is unplugged instead of disappearing when any USB device is unplugged.
- Bug fix: EjectUSB will no longer display an error if WMI functions fail.
- Improvement: EjectUSB's ejection success message now displays the ejected drive's name.
- Addition: Added /ini command line argument to allow a settings file to be specified.
- Addition: Added /settings command line argument to display a settings interface window.
- Addition: Included Settings.bat with the download to make adjusting settings easier.
- Change: Modified the manifest information.

Version 1.4 (88989 downloads)
- Bug fix: Graceful program closing no longer only targets programs with a visible window.
- Bug fix: Flushing file buffers can no longer cause ejection to fail.
- Improvement: Dead tray icon cleanup is more resilient and slightly faster.
- Improvement: EjectUSB can now generate its own ejection success message. This will make ejection seem much faster on most computers.
- Addition: Added NoFakedMsg setting to the configuration file format.

Version 1.3 (107575 downloads)
- Bug fix: Program closing on Win9x works again (was broken in 1.2).
- Bug fix: Fixed issues on Win9x when running EjectUSB from a drive's root folder.
- Improvement: Implemented hybrid batch scripting. This provides theorhetical support for TrueCrypt and combination flash card / flash drives as well as conditional operations.
- Improvement: EjectUSB can now interface with EjectMedia.exe to eject flash cards / CDs.
- Improvement: Implemented support for Subst.
- Addition: Added DoNotSubst and NoRedirect settings to the configuration file format.
- Addition: Added /nobat command line argument to disable use of the hybrid batch file (if present). Meant to be used within the hybrid batch file if starting another instance of EjectUSB to prevent infinite loops.

Version 1.2 (4933 downloads)
- Bug fix: Improved handling of relative paths (\ and ..).
- Improvement: Implemented API-based ejection.
- Improvement: Implemented file cache flushing. Requires admin privileges.
- Improvement: EjectUSB can now interface with Sync (from Sysinternals) to flush the file cache (instead of using its own internal file cache flushing function). Requires admin privileges.
- Improvement: Improved command line argument parsing; drive letter or folder path no longer are required at all and no longer must be the first command line argument.
- Improvement: Efficiency improvements related to DLL calls.
- Addition: Added DoNotFlush and NoEjectAPI settings to the configuration file format.
- Change: RemoveDrive.exe is called with the -L switch to loop until successful ejection. This can be aborted by closing the RemoveDrive.exe console window.
- Change: DevEject.exe is now launched hidden.
- Change: Added current version number to EjectUSB.exe version info.

Version 1.1 (3413 downloads)
- Bug fix: Improved ejection capability via EjectUSB's own internal ejection routine.
- Bug fix: Improved command line argument and input parsing for handle.exe; there were some formatting differences between the output on Win9x and WinXP.
- Bug fix: TimeToWait is now a maximum per ''phase'' rather than per program; in rare cases EjectUSB could wait for multiple minutes on closing programs with the default TimeToWait value of 5 (seconds).
- Bug fix: Cleaning up dead tray icons was triggered by faulty criteria; in simple terms, dead tray icon cleanup was occuring when it didn't need to (wasting up to 1 second).
- Improvement: Minor efficiency improvements related to the previous two changes.
- Improvement: EjectUSB can now interface with Unlocker to close open file handles; simply UniExtract the Unlocker installer and put Unlocker.exe and UnlockerDriver5.sys in the same folder as EjectUSB. Unlocker requires admin privileges and doesn't work on Win9x.
- Improvement: Added a FAQ section to the documentation.
- Change: Slight change to the EjectUSB logo.
- Change: Separated the source code into its own ZIP file. Source code for EjectUSB will always be released with each version of EjectUSB.

Version 1.0 (1695 downloads)
- Initial release.

[ 07 August, 2009 ] • [ William Hedrick ] • [Bookmark and Share]

Comments (141)

[ Page 2 of 8 ] • [ << | < | 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 | > | >> ]

I'm a bit of a software geek. I install dozens of programs every week, but I can't figure out why this program does not work on my XP SP3.

I run it and it just creates an icon in the system tray. Why does it need to be in the system tray if the only option is to "exit"?. Does it have to be run from the command line then?
[ 22 July, 2008 ] • [ frustrated ] • [ 11:56:30 ]

Heh, the answer to that is actually one of the few things in the FAQ:

- My drive hasn't ejected and there's an EjectUSB icon in my system tray, what's wrong?

EjectUSB is repeatedly trying to eject the drive but is failing; click the EjectUSB tray icon and choose Exit, make sure the drive is not in use, and then try again.

Depending on the circumstances, this step (where the icon's in the system tray) can take 10+ seconds. Also, if you're running EjectUSB from a non-ejectable drive and EjectUSB is still trying to eject the drive, that icon will probably just sit there forever (until you exit it).
[ 22 July, 2008 ] • [ William Hedrick ] • [ 13:03:37 ]

I tried 3 versions on 2 machines, and it's never work with me !
[ 24 July, 2008 ] • [ ameer ] • [ 05:38:48 ]

oh, I read now some comments, I am not alone.

This program is NOT work.
[ 24 July, 2008 ] • [ ameer ] • [ 05:41:11 ]

My USB flash was ejected but when I plugged it back in a message came up saying an "unsafe eject was performed and some files may have been lost" or something along those lines. No files were lost but I did have a nervous moment there.

Sandisk 8 GB U3 "Cruzer"
[ 24 July, 2008 ] • [ James Howell ] • [ 06:17:54 ]

Can this be used to disconnect a recalcitrant external hard drive? I have a Seagate 160 GB that my Vista Home Premium refused to let go. I closed every open program and the OS kept telling me to come back later. To safely remove the drive I ended up shutting down the computer. Very inconvenient to say the least.
[ 24 July, 2008 ] • [ Bob Oh Bob ] • [ 11:07:36 ]

It has the potential to work for that Bob. EjectUSB is capable of ejecting an external hard drive, but whether it will solve whatever your particular issue is will simply require testing. At worst, EjectUSB won't be able to eject it either.
[ 24 July, 2008 ] • [ William Hedrick ] • [ 14:10:40 ]

James, a message telling you the drive wasn't safely removed isn't a function of a standard USB drive, so I'm assuming it's a function of the U3 software on your Cruzer. I have a Cruzer lying around somewhere that I can test EjectUSB with and see if I can come up with anything.

If anyone's curious, my primary USB drive is an older 1GB PNY Attache with read-only switch.
[ 24 July, 2008 ] • [ William Hedrick ] • [ 17:23:54 ]

I used this and it worked great until I came to plug my USB drive in the next time and now it isn't recognised. The drive works on my other PC's but no longer on my main one which is very frustrating. Can you help? If not I'm going to have to buy a new drive.
[ 29 July, 2008 ] • [ Jaye ] • [ 23:56:48 ]

A couple things to keep in mind:
- EjectUSB doesn't do anything radical to eject your drive, it follows standards Windows routines for ejecting a drive and is essentially no different than if you used the safely remove hardware dialogs yourself.
- Its registry cleanup doesn't edit or delete any fragile parts of the registry and doesn't leave any entries in invalid states (even if your system crashed during registry cleanup there should be no ill effects).

If one computer isn't recognizing your drive, but other(s) are, it's either a hardware or software issue with the one computer. My first thought would be to check that the USB plug on the computer isn't dirty (it's not unusual for dust/lint/hair to collect in a USB port); you might as well check the USB connector on the drive as well to be sure it's clean.

Next I'd make sure it's not a non-present storage device issue of some sort. You can use DriveCleanup by Uwe Sieber to deal with this automatically:
http://www.uwe-sieber.de/dr...

Beyond that I'll need more information to try and help look for a solution, namely the brand and model of removable drive. I've never encountered this problem before but believe me that I sympathize with you; I'd be livid if my computer stopped recognizing my flash drive.
[ 30 July, 2008 ] • [ William Hedrick ] • [ 01:30:31 ]

Hi , the app sounds like what i need , but i must be missing a point somewhere.
Do i install it on the usb drive itself ?
So far i've extracted the files to a folder i've created in my program files, and placed a shortcut on my desktop, plugged in my usb drive, purposely left a document open clicked the desktop shortcut and nothing happens.
Even clicking the icon directly from inside the program file doesn't provoke a reaction.
I've read the documentation and comments here but i'm still no wiser.
I'm using vista as an admin.

So at the moment i'm thinking i have to install it on every usb drive individually ?
Any help from anybody would be welcome...
[ 30 July, 2008 ] • [ Robert ] • [ 02:51:38 ]

EjectUSB worked perfectly for me .. much faster than Windows safely remove hardware ... but, our virus scanner at work identified it as a trojan and removed it from my machine. Any way to bypass this?
[ 30 July, 2008 ] • [ James ] • [ 03:32:52 ]

@Robert, yes EjectUSB is meant to be put on the removable drive itself and run from there, however, it can be used from a fixed drive (to eject a removable drive) by specifying the removable drive's drive letter in the command line to EjectUSB. For example if the removable drive is drive letter F, you'd run
EjectUSB.exe F
(or EjectUSB.exe F: or EjectUSB.exe F:\)
This could be accomplished via a shortcut or a batch file for example. Hybrid batch scripting provides a mechanism to automatically detect removable drives and so could be used to automate this process (rather than needing a shortcut with a fixed drive letter specified) however it still needs further testing before I release such scripts publicly.

@James, it's a side-effect of EjectUSB being an AutoIt3 script. Do you know the name of the virus scanner your work uses so I can submit a false positive report to them? In addition, I'll be able to test that virus scanner in particular (assuming they have a free trial or it happens to be an AV which I have access to a licensed version of) and see if changes to executable compression can avoid a false positive. If you have any concerns you can visit http://www.autoitscript.com... and peruse the EjectUSB source code to be sure it's clean. That's the downside with false positives, you're sort've guilty until proven innocent if the AV program automatically deletes the program. =/
[ 30 July, 2008 ] • [ William Hedrick ] • [ 21:13:57 ]

Hi, thanks for you suggestions. I've tried the following:-
* Running DriveCleanup
* Uninstalling the drivers.
* Tried plugging the drive into all 7 USB slots in my PC.
The drive is a Trancend Jetflash V90 Classic. It works on every computer I've tried it on apart from the one PC I used it with EjectUSB.
It makes a noise when I plug in the drive and remove it but doesn't show in My Computer. (also after unistalling the drivers it did reinstall then on insertion but still did not show in My Computer)
I've also tried other USB drives on this computer and they work fine.
The PC is only 2 months old.
Let me know if you need any further info.
[ 30 July, 2008 ] • [ Jaye ] • [ 23:14:22 ]

dude
thanx alot
[ 01 August, 2008 ] • [ the crazy jogger ] • [ 16:19:51 ]

Hi William, thanks for your answer, even though it's a bit late on my part, i've been busy doing this and that. Your explanation has helped me understand what's what and why and how to proceed. I'll install it later on in the day on my external drives. Thanks for the software, i'm sure it'll help a lot of people who have this problem. I tip my hat to you :)
[ 04 August, 2008 ] • [ Robert ] • [ 23:21:28 ]

Well done. Always wanted to write this thing.
Thanks!
[ 07 August, 2008 ] • [ Pierre C. ] • [ 04:51:06 ]

Jaye, I had the same problem as you and instructions here:
http://techrepublic.com.com...
solved the problem for me. That link also has a section "People who read this, also read..." that has other similar problems and solutions. I hope one of the solutions there works for you.

William, thanks for EjectUSB, it's been real handy.
[ 07 August, 2008 ] • [ Yonni ] • [ 13:14:52 ]

bonsoir je le voudrais en francaiss.v.p
[ 08 August, 2008 ] • [ guilbeault ] • [ 17:54:14 ]

Great tool!! Is there any way to make it eject faster? It closes all progs fast but it sits there for what seems very long before it shows the "OK to remove" type message. I've tried to turn off the following and it's still slow. Otherwise it's Awesome!
[Settings]
TimeToWait=3
DoNotFlush=1
DoNotClose=0
NoPrograms=0
NoGraceful=0
NoExplorer=0
DoNotClean=1
NoRegistry=1
NoFirewall=1
NoShortcut=1
DoNotSubst=0
NoRedirect=0
DoNotEject=0
NoEjectAPI=0
[ 11 August, 2008 ] • [ Jim ] • [ 07:43:01 ]

[ Page 2 of 8 ] • [ << | < | 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 | > | >> ]

Add Comment