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, 138197 downloads)
» Source Code (26 kilobytes, 11985 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 (157)

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

@Andrew, thanks for the bug report; I'm fairly certain I've located the error and corrected it. When version 1.5 is released, I'd appreciate it if you stopped by and let me know. Heh, assuming you see this reply. =)
[ 20 January, 2009 ] • [ William Hedrick ] • [ 16:15:29 ]

I can say only 1 thing: Thanx for this great little utility!
[ 20 January, 2009 ] • [ Max011 ] • [ 17:21:16 ]

Thanks for replying, William.
When do you think version 1.5 will be available? Can I get a beta version?
[ 22 January, 2009 ] • [ Andrew ] • [ 08:57:46 ]

I still have a few test situations I'm waiting on results from, so don't have a release date set for 1.5 (typically I update immediately once a new version is ready and testing is done).

I'm terribly busy this week, so don't expect the full release until after the weekend at the earliest (this beta version may be used as the release version if no more bugs are found).
[ 22 January, 2009 ] • [ William Hedrick ] • [ 12:39:50 ]

PENDRIVE DE 8 GB KINGSTON BLOQUEADO NO PERMITE COPIAR O BORRAR APARECE MENSAJE QUE DICE QUE ESTA BLOQUEADO
[ 28 January, 2009 ] • [ EMILIO ] • [ 16:09:27 ]

I'm on ur website, leavin u a comment.
Shout-out to Will$
[ 30 January, 2009 ] • [ Gimp ] • [ 22:35:59 ]

Why does Kaspersky warn me that EjectUSB has changed every time I use it?
[ 02 February, 2009 ] • [ Dave ] • [ 14:53:21 ]

I'm afraid I don't have a sure answer for that Dave. =/ EjectUSB isn't self-modifying. It does make a temporary copy of itself (when ejecting, as do all drive ejection utilities) so I suppose it could be responding to said copy. Does Kaspersky give a file location in its message that tells you EjectUSB has been modified?
[ 03 February, 2009 ] • [ William Hedrick ] • [ 12:49:31 ]

It doesn't give a location, only a process ID. Your app does it's job and ends, I'd say, before I get the warning. EjectUSB is a nice little app. The eject utility built in to PAM Mod R34 is more cumbersome, leaving the open dialog box, but it doesn't cause Kaspersky any grief.
[ 03 February, 2009 ] • [ Dave ] • [ 19:20:26 ]

Well, I'll certainly explore some options. I have some new plans for the self-deleting copy that's necessary for the final ejection step, but the new method won't be available until version 1.6 and will have to undergo a fair bit of testing to make sure it works the same on all versions of Windows (1.5 is done and will be released this week). Regardless, thanks for reporting the issue, bug-fixing and compatibility (especially with anti-virus software -_-) are my top priorities.
[ 03 February, 2009 ] • [ William Hedrick ] • [ 20:00:07 ]

Version 1.4 is very nice and work perfect in the PortableApps launcher
[ 01 March, 2009 ] • [ TAN ] • [ 06:25:34 ]

This program works great! This is what my library uses. They used to not have a safe "Eject" process. But no they do! Thanks so much!
[ 05 March, 2009 ] • [ Michael Tarr ] • [ 14:21:49 ]

Trying to use with win98se and SanDisk Cruzer Micro 2 Gig. If I copy EjectUSB.exe to the Cruzer, and then double click on the Icon, that window goes away immediately. However
the light on the Cruzer remains on and the drive letter (E) still shows in the "My Computer" window and the drive is still accessable. For example I can double click on
EjectUSB.exe and the same things happen. I a reluctant to remove the drive with the light
and thus the power still on the device.

When I use the Cruzer on my other computer with Windows XP, I use the Safely Remove Hardware Icon and then click on the Cruzer entry. The light goes out and a message comes up that I can safely remove the device.

I also tried to use your program with command line options from a Dos Box and It keeps giving me the error message "Invalid drive or folder Specified." Even though I follow the format shown in your response to @Robert 30 July 2008 above.

Any help would be appreciated, Thanks
[ 12 March, 2009 ] • [ EngTech36 ] • [ 14:51:48 ]

I am interested in posting about this application on my blog but I keep running into problems when using it. Mainly, Wordpad/Notepad/Word files won't close.

I hope this is fixed soon because I find this program to be excellent.

Thanks.
[ 19 March, 2009 ] • [ Ashraf ] • [ 21:52:54 ]

Hello,

I downloaded EjectUSB zip file and created EjectUSB.exe.

When I run it from the command line, as

EjectUSB.exe /eject H:\

no message is printed and the USB drive is not removed.

What am doing wrong?

thanks
[ 03 April, 2009 ] • [ srpfl ] • [ 12:15:26 ]

First, let me say this app is great.

It's just that "Exclusions" don't seem to work for me.
I have all my apps in a "Program Files" directory on my thumbdrive. I list my exceptions in the ini file like so:
//////////////////
[Exclusions]
0=PStart
1=Pocket
2=Portable
3=revouninstaller.exe
4=keepass
5=truecrypt
///////////////////
But EjectUSB closes them anyways. I have a batch file that closes TruCrypt and KeePass, so I would like EjectUSB to ignore those programs. It also closes the portableapps menu.

I wasn't sure if I should address the paths but I tried the complete path, and relative paths. Any help with this would be greatly appreciated.
[ 03 April, 2009 ] • [ John Woo ] • [ 16:36:04 ]

@John Woo, The problem you're running into is that Exclusions don't actually keep EjectUSB from closing them; you're not doing anything wrong. All it does is not close them until EjectUSB's second pass on closing programs. Adding true Exclusions that EjectUSB won't close is additional functionality I intend to add someday.

@srpfl, First try just EjectUSB.exe H:\. If that still doesn't work, it's hard to say what the exact problem is; have you tried copying EjectUSB.exe to the drive you want to eject and just running it from there?

@Ashraf, closing files on the removable drive opened by a program not on the removable drive will only work if you have handle.exe or unlocker.exe in the folder with EjectUSB.exe AND if you had admin privileges.

@EngTech36, Cruzers can be troublesome to eject automatically. =/
[ 13 April, 2009 ] • [ William Hedrick ] • [ 17:01:28 ]

Great utility!!!

One question - is it possible to launch ejectusb from a folder on the C drive and eject a specified USB stick, say, an F drive?

Steve
[ 14 April, 2009 ] • [ Steve H ] • [ 10:49:08 ]

Yes, you could, for example, run "EjectUSB.exe F" to have it eject the F drive. You could do this by making a shortcut, or a batch file, or typing out the command manually. I don't think EjectUSB has drag-and-drop support (I've never tried) for that sort of thing (drag your F drive onto EjectUSB.exe) so I'll see about adding that in version 1.6.
[ 14 April, 2009 ] • [ William Hedrick ] • [ 19:16:27 ]

EjectUSB forces applications to close, so that they can't save their settings, and Exclusions doesn't work (PStart.exe still terminated).
I've tried TimeToWait=30, NoGraceful=0 and then also NoGraceful=1, DoNotEject=1 but nothing works.
I'm launching EjectUSB from substituted disk.

WinXP SP2, EjectUSB 1.5
[ 25 April, 2009 ] • [ Dima ] • [ 09:18:14 ]

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

Add Comment