EjectUSB

EjectUSB
Version 1.5
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.5:
» Download EjectUSB (258 kilobytes, 148490 downloads)
» Source Code (26 kilobytes, 3498 downloads)

Change Log:
Version 1.5
- 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.

[ 13 April, 2009 ] • [ William Hedrick ]

Comments

Perfect tool for my pen drive ;)

Thanks
[ 14 June, 2008 ] • [ Dangu ] • [ 10:20:54 ]

The program is not good!
Please work for it!!
[ 14 June, 2008 ] • [ Ciccioformaggio ] • [ 12:25:51 ]

@Ciccioformaggio

Please give some constructive criticism, like what exactly you found that didn't work well. What you just said doesn't help the developer and will not get your problem fixed.
[ 14 June, 2008 ] • [ m-p{3} ] • [ 19:49:52 ]

nice program
[ 15 June, 2008 ] • [ martik ] • [ 01:59:54 ]

This Is Great.... I was looking for a App like this that was not running all the time and I could use to eject my Ipod......thx
[ 15 June, 2008 ] • [ Wid ] • [ 19:57:03 ]

If EjectUSB isn't reliably ejecting your drive, please feel free to leave a message here stating as much and include the version and language of Windows you're using.

Consider downloading one of the ejection helper utilities listed in the EjectUSB documentation; I personally use RemoveDrive (which I've successfully used on XP and Vista). I only rely on EjectUSB's ejection routine when using Win98SE; all of the ejection helper utilities listed in the documentation eject a drive via the Windows API while EjectUSB manipulates Windows' Safely Remove Hardware mechanism via macros.
[ 16 June, 2008 ] • [ William Hedrick ] • [ 02:01:35 ]

Amazing
[ 20 June, 2008 ] • [ Professor ] • [ 05:26:52 ]

Eject USB is excellent portable
[ 20 June, 2008 ] • [ Tani ] • [ 15:10:08 ]

Excellent application. It's the most usefull portable I have on my flashdrive. GREAT GREAT GREAT WORK! Thank you for this!
[ 20 June, 2008 ] • [ f1xxx3r ] • [ 16:49:14 ]

thanks for this great program!
[ 20 June, 2008 ] • [ dude ] • [ 21:52:54 ]

nice work , i use it , but in windows vista after run this software some process display on screen like send watch icon dispaly in notification area this is good
but also my moniter screen blank for some neno seconds.

if you hide some process .
i think this is best software after it

thanks for this free software
[ 22 June, 2008 ] • [ ashish ] • [ 04:15:59 ]

IS VERY NICE

WHAT CAN I DO WITH FOLDER Source Code?
CAN WORK Eject USB WITHOUT » Source Code?
[ 05 July, 2008 ] • [ TAN ] • [ 06:47:47 ]

This is great. I would love to see support for truecrypt container drives. i.e. Shutdown all applications running in Truecrypt mounted drive, unmount truecrypt volume, and exit.
[ 05 July, 2008 ] • [ gig ] • [ 07:44:54 ]

@TAN, You do not need the source code for EjectUSB to work; it's there so you can ''compile'' it yourself if desired.

@gig, I'll look into TrueCrypt support. I don't expect it to be too difficult to implement.
[ 05 July, 2008 ] • [ William Hedrick ] • [ 08:43:06 ]

Very nice app!

I am having a small usage problem with it. At home I use a card reader and at work I use direct usb (I have one of those Sandisk SD with USB cards). On my work machine I want all my apps and directories to close and the drive ejected. At home, I want all the apps and dirs to close, but no ejection to occur. If an ejection does occur on a card reader, the whole card reader is ejected from the system and I have to reboot to get it back.

Would there be a way to make EjectUSB detect if a drive is connected through a card reader and not perform the ejection? (If a usb mass storage device has multiple volumes hanging off of it, it is most certainly a card reader.)

Alternatively, would it be possible to specify an .ini file on the command line? A batch file could then be used to detect the hostname and launch EjectUSB with different .ini files to get different behavior.

Thanks!
[ 05 July, 2008 ] • [ Joe Stadolnik ] • [ 09:05:30 ]

At the very least I'll add command line support for specifying an INI file. I may also add command line setting overrides as well (for example, /noeject would supersede the setting in the INI file so while you'd still need the batch file, you wouldn't need separate INI files).

Currently (v1.2) you could accomplish what you're asking for by making a copy of EjectUSB.exe and renaming it; whatever you name the executable, it will look for a matching named INI file to go with it, so you could have two separate EXEs and INIs in the same folder and a batch file to launch the one for the current situation.

However, I'd like to resolve the issue at its root and add proper support for card readers. I can't give you a timeline on card reader support because I'm not sure how complicated it will be; it might be simple, or it might require a whole seperate routine to eject just a specific card (as opposed to ejecting the entire card reader device).
[ 05 July, 2008 ] • [ William Hedrick ] • [ 09:31:25 ]

First tests show Version 1.3 (7/20/08) has apparently fixed my reported problems with 1.2 not closing QSEL. Thanks, now I can quit using 1.0.
[ 20 July, 2008 ] • [ Steen ] • [ 11:01:43 ]

Hello,
Do you have an example of the batch file to unmount a truecrypt partition?
There is nothing included in 1.3 distribution and no documentation!

Cool tool btw!
ty
[ 21 July, 2008 ] • [ joe ] • [ 08:36:48 ]

I'm working on the hybrid batch scripting documentation over the course of this week. I wanted to get 1.3 released since it has a couple bug fixes. Example hybrid scripts and documentation will be added as a separate download when they've been fully tested (which they basically are) and are safe and ready for public use.
[ 21 July, 2008 ] • [ William Hedrick ] • [ 10:45:35 ]

Thanks for the update!
[ 21 July, 2008 ] • [ joe ] • [ 16:22:48 ]

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 ]

@jim
Sorry for the question? According to the FAQ, I guess you can't :-(
Jim
[ 11 August, 2008 ] • [ Jim ] • [ 08:36:32 ]

What's the license? I'd love to use this in the office, but they won't let me unless you explicitly state that it is ok (it works great at home, though - thanks!
[ 11 August, 2008 ] • [ Anne O-nymous ] • [ 23:42:56 ]

Is there a way to put this in the PortableApps launcher?
[ 12 August, 2008 ] • [ dov717 ] • [ 20:04:05 ]

do i need to put deveject in the same folder as the eject usb?
[ 13 August, 2008 ] • [ dude ] • [ 06:51:11 ]

additional question:

do i need to put all the extra app (bold ones) inside ejectusb folder?
currently these are the bold ones that i can see (see below), only unlocker and sync are the two that i put inside ejectusb folder.

EjectMedia.exe
Sync.exe
RemoveDrive.exe
DevEject.exe
handle.exe
Unlocker.exe

what does it mean that it can interfaced? should i put the apps inside the folder?

thanks for the great app
[ 13 August, 2008 ] • [ dude ] • [ 07:11:04 ]

je le veux
[ 13 August, 2008 ] • [ maximebergeron ] • [ 09:16:44 ]

Your blog is interesting!

Keep up the good work!
[ 17 August, 2008 ] • [ AlexM ] • [ 16:33:00 ]

I use W98SE and I have two programs which are similar but not identical (one on my hard drive and the other on my USB sticks).

I would very much like to try your program and I would like to ask, should any conflict arise, can I uninstall or delete your program?

I would add that I definitely need my original programs so it is coexistence which matters.

My regards
[ 25 August, 2008 ] • [ Mike ] • [ 10:26:36 ]

Is there a way to add command line switches to the External Utility Support? I was specifically looking at "USB_Disk_Eject.exe /REMOVETHIS /SHOWEJECT" I would like to use this External Utility because it promptly removes the USB drive, but it does not give me a notification when it has been removed.
[ 19 September, 2008 ] • [ MikeT ] • [ 11:01:09 ]

Hello,

i haven't the same ejection on xp and vista...
On vista my usb stick stay lit when she switched off on xp ... I preferred before !
Could it be that even extinguish it with Vista?

thanks for this very good and free app.
[ 30 September, 2008 ] • [ Totoche ] • [ 14:39:10 ]

thakyou
[ 04 October, 2008 ] • [ thanh ] • [ 20:54:22 ]

Hey, this is just great! God only knows how long I have been looking for a little utility like this! Especially my ancient Lexar JumpDrive with the secure partition does not take kindly to suddenly being jerked out of the USB port because nothing in the world will stop it. I have tested EjectUSB several times, and despite the warning messages everything turns out just fine. Thanks so much for making this program available for free!!
[ 05 October, 2008 ] • [ beattheswiss ] • [ 07:14:09 ]

at home I have a decent virusscanner (NOD32), installed it.

this is a beautiful piece of software! thanks a lot!!!!!!!!!

wow, you even thought of a no-eject setting! this is great, now I can close all open apps before firing up my backup program!!!!

thanks again!!!

tony
[ 08 October, 2008 ] • [ tony ] • [ 14:48:50 ]

Also have the MacAfee issue. Detected as a generic.dx trojan. Any ideas?
[ 09 October, 2008 ] • [ foobar ] • [ 07:14:47 ]

Yeh I have the same problem. EVEN bigger issue, as the uni im at runs Macafe, and auto deletes the exe in insertion! grrrrrr!
[ 09 October, 2008 ] • [ relequestual ] • [ 12:46:49 ]

McAfee temporary workaround:

McAfee false positive is related to UPX code, which is opensource compression code. The script wrapped without UPX generates a bigger .exe, but without false positives in McAfee

it is explained in this forum:
http://www.autoitscript.com...

the REAL solution is to:

contact McAfee, and politely inform them their AntiVirus generates false positives. send them the EjectUSB.exe, and point them to this page where they can check the errors, source, contact the author etc.

please DO contact McAfee, they probably wont give much priority on 2 or 3 error reports. more is better in this case!

thanks!
[ 13 October, 2008 ] • [ tony ] • [ 03:55:31 ]

ehm, listed SyncBack in the [exclusions] list but still gets closed.
pstart is closed too btw.

am I doing something wrong?
[ 13 October, 2008 ] • [ tony ] • [ 11:35:27 ]

Hi,

Any Hybrid batch script example available?
[ 15 October, 2008 ] • [ Gig ] • [ 08:44:41 ]

Hi, I'm currently using a Truecrypt volume on a usb drive running geek.menu (a PortableApps fork). geek.menu allows me to configure an ejection application to be run when I click on the eject option but it is only able to run the application once. It is capable of passing both the usb drive and the truecrypt drive to the application as parameters.

My current solution (currently untested due to lack of space) is a batch file (i run this directly from geek.menu, not via ejectusb) which first runs noejectusb.exe x: (renamed copy of ejectusb.exe) with donoteject=1 in the noejectusb.ini to close all the apps on the truecrypt volume, unmount the truecrypt volume using truecrypt.exe and then run ejectusb.exe w: to unmount the usb drive. This takes up too much space since there's 2 copies of the exe and the free space on the actual usb drive isn't enough due to the large truecrypt volume file.

Will it work with just one exe and one ini file with donoteject=1 and then just run ejectusb.exe x: to close apps on the truecrypt volume and then run ejectusb.exe /eject w: to close all apps on the usb drive and eject it? Will this method actually close the apps running on the usb drive and flush it as well?

Or, for the most elegant solution I can think of, is there a way to specify multiple drive letters to eject and have different hybrid batch files for each drive? I'm trying to find a way to call ejectusb.exe directly and give it 2 drive letters like this: "ejectusb.exe x: w:" and let ejectusb.exe close the apps on the truecrypt volume, run a .bat file for the truecrypt volume to unmount it eg: "ejectusbtruecrypt.bat x:" and then do the normal eject stuff for the usb drive.

The drive letters btw may be different and are provided by geek.menu to the eject script/application via command line.
[ 20 October, 2008 ] • [ jaybz ] • [ 22:35:44 ]

thanks
[ 22 October, 2008 ] • [ Nobunaga ] • [ 19:59:58 ]

Hi everyone,

sorry but what is exactly a "hydrid" batch file ?

anyway great app !!!
[ 30 October, 2008 ] • [ BillyBoy ] • [ 04:08:23 ]

well, turns out i don't need the hybrid batch file at all. i have ejectusb.exe and the ini file on both the usb drive and truecrypt volume and i created a .bat file to be run by geek.menu upon clicking the eject button. one thing to note is that the .bat file accepts the host drive letter as the first parameter, and the truecrypt drive letter as the second, the reverse of geek.menu's default, which you can change yourself. i haven't tested it yet, but the .bat file should allow ejecting even if you checked the option to not mount the encrypted volume on the password prompt. the contents of the .bat file is below for geek.menu users who are interested. you could also probably use it for other usb menu software after some or no modifications. enjoy.

contents of eject.bat:
@echo off
if "%1"=="" goto xit
if "%2"=="" goto ejecthost
%2:\EjectUSB.exe
%1:\TrueCrypt\TrueCrypt.exe /d%2 /q /w /s /f
if errorlevel 1 goto xit
:ejecthost
%1:\EjectUSB.exe
:xit
[ 03 November, 2008 ] • [ jaybz ] • [ 21:30:14 ]

sorry, forgot to note that the ejectusb.ini i used on the truecrypt volume has DoNotEject=1
[ 03 November, 2008 ] • [ jaybz ] • [ 21:31:13 ]

desbloqueo de un pen drive
[ 12 November, 2008 ] • [ alejandro ] • [ 15:42:00 ]

Hi,

I have a suggestion for feature :
The possibility to have an other ejectUSB.ini, that we can launch in parameter.
Example : EjectUSB.exe "ejectUSBbis.ini"

It's because i use eject usb for two principal reasons without the same option ...

Thanks
[ 20 November, 2008 ] • [ Totoche ] • [ 07:56:02 ]

Thank you for this great little application. It took me a couple tries then I read the 'read me' and understood that the application needed to be on the device being removed. Makes sense. I put it on each of my removable devices and now I save a lot of time and frustration. Great Job!
[ 27 November, 2008 ] • [ Didier de Gery ] • [ 19:39:45 ]

An excellent program, works at school, but at home avast hates it.
[ 16 December, 2008 ] • [ Some dude ] • [ 16:30:39 ]

Hello,

Cool ! The new 1.4 is faster.

The only little problem stay to close firefox (portable) ... He think it's a crash at the next start!...

Thank you
[ 16 December, 2008 ] • [ Totoche ] • [ 16:58:50 ]

Thanks for your excelent tool, which saves me a lot of time.
Question: when do you expect Truecrypt support?
And it would be nice if you had some forums :D
[ 17 December, 2008 ] • [ mnt_schred ] • [ 18:28:51 ]

Sorry, didn't see the .bat script. You have made a relative path to truecrypt?
[ 17 December, 2008 ] • [ Thijs ] • [ 18:38:31 ]

Thanks William, EjectUSB 1.4 is VERY fast.

Merry X-mas!
[ 20 December, 2008 ] • [ Ricky999 ] • [ 15:18:28 ]

Unlocker found no handles. Searching Mark Russinovich's SysInternals ProcessExplorer for and handles to my WD Passport yielded nothing. And yet your nifty little program managed to eject my USB drive. I have no tasks or processes that were working with my USB drive. And yet, Windows won't gracefully eject my drive for some reason (it says that some program is still accessing it). My TaskList is clean, no malware, no hidden stuff, no rootkits, nothing! Now, how did your program manage to do it?

I have my WD Passport formatted in NTFS (512 bytes sized clusters, am a space freak) but it used to eject gracefully without qualms in the past. Recently, I've noticed that the hard-to-eject anomaly is happening too frequently for comfort. Should I suspect NTFS at (foul) play?

I am somewhat freaking amazed here. How the f did your little program do it? I've read all your blahs in the read me but I found no (ZERO) references left to my drive according to my own investigation! What's the secret?
[ 20 December, 2008 ] • [ Loloy D ] • [ 18:20:57 ]

I see that you have this open-sourced. I'll take a look at the code and see how you were able to pull this off. I suspect that my problem still remains with System Volume Information (or SVI) - a folder on the root of NTFS drives or partitions.

You said that your program doesn't do anything "unsafe" and that it only works with Windows APIs. That's actually really very comforting - add to that where you made this thing open source. And you have a clean way out disclaimer too, and you made this app with noble intentions, so I believe you got everything covered. I said this because I don't quite appreciate some of the comments above in this blog which say "this program doesn't work" or "this screwed my drive", etc.

By the way, I think it is worth mentioning that the way I was able to eject my USB drive was by using the aggressive mode "/eject" argument. I was not able to eject my WD Passport without it. From what I understand of your ReadMe, this argument "ignores configuration file settings and attempts to eject the specified drive; this bypasses all other functions (program closing, registry cleanup, etc.)." This leads me to conclude that there could be some Windows system process refusing to let go of my USB drive - again, probably has something to do with SVI. What bugs me is that I am not able to find any references to it from SysInternals ProcessExplorer. You should highlight that "/eject" argument for those difficult cases.

By the way, I failed to mention THANK YOU. Your work has indeed provided meaningful, sensible, usable and reliable functionality to me, not to mention saving from me a small server downtime and from lots of wasted time trying out stuff and experimenting to nowhere. Hmmm... come to think of it, I've also spent a lot of time too from reading this blog entry hehehe - but it has had its fruitful uses :D.
[ 21 December, 2008 ] • [ Loloy D ] • [ 17:34:39 ]

Hello,

I'm using Windows Vista and this app works great only I don't get a message balloon on successful ejection.
Is this a bug?

It did removed the USB disk.....
[ 31 December, 2008 ] • [ Grolo ] • [ 06:29:48 ]

@Loloy D, thanks for the kind words and I'm glad EjectUSB's been useful for you. Technically, /eject is LESS aggressive than running EjectUSB with default settings; all it does is run the ejection routine (which loops continuously until it succeeds). Using /eject, you miss out on the file cache flush (useful for external hard drives especially, though only works if you have admin privileges) and the various cleanup routines. Obviously if that works while default EjectUSB settings don't, stick with what works.

NTFS is a journaling file system, meaning there is a lot of behind-the-scenes note-taking (and therefore disk writes) that occur in addition to basic file operations; it provides a layer of safety against file corruption and loss, and theorhetically makes recovery from some critical errors trivial, but it also means the disk may be in use by the system even though you're not directly using files anymore. Regardless of the downsides, it's a good choice of file system for any hard drive due to reliability and error recovery (though you should not use it on a flash drive).

@Grolo, yes, the lack of an ejection success message balloon is a bug that I'm currently working to track down; it doesn't occur on any of the computers I have available (ranging from Win98SE to Vista SP1), so I've asked some beta testers to try and get me more information on the issue. My first guess is it's a unicode or non-English language issue. Version 1.5 is in the works though and I hope to get that issue resolved before release.
[ 11 January, 2009 ] • [ William Hedrick ] • [ 22:04:43 ]

Hello,
Avast detect a virus on EjectUSB ... can we fix it?
[ 13 January, 2009 ] • [ marciton ] • [ 15:06:24 ]

@marciton, make sure you have version 1.4; it's not setting off Avast (at least any version of Avast I've tried). Version 1.3 was the version primarily detected (falsely) by Avast.
[ 13 January, 2009 ] • [ William Hedrick ] • [ 15:48:42 ]

bonjour a tous
quand à l'utilitaire ejsct fflash USB il est très éfficasse,point de sécurité
pour l'usb storage et aussi pour la rapidité de son ejection.
trés bon travail qui mérite un grand encouragement et je vous souhete une
très bonne reussite à l'avenir,jje vous remerci,au revoir.
[ 14 January, 2009 ] • [ ramdaneastro ] • [ 09:01:36 ]

--------------------------
My first guess is it's a unicode or non-English language issue.
--------------------------

@William
I have a dutch windows vista so I think it's a good guess
[ 14 January, 2009 ] • [ Grolo ] • [ 14:29:11 ]

The program works for me, in that it closes programs and ejects the drive, but after a few seconds, I get an AutoIt error every time. It reads:

Line -1:

Error: The requested action with this object has failed.

I have not changed the configuration files that come with the program.
[ 19 January, 2009 ] • [ Andrew ] • [ 10:13:09 ]

@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 ]

Ok, maybe Exclusions works on "1st pass", I can't see it anyway, but how can I be sure, that wrappers will have time for saving their settings? I think EjectUSB should wait for their own, self-dependent termination.
[ 25 April, 2009 ] • [ Dima ] • [ 10:38:38 ]

Portable wrappers typically get their job done in under a second; a TimeToWait of 30 should easily give even a slow operation (copying some sizable settings file to a flash drive) plenty of time to complete. I highly recommend you set NoGraceful to 0 and be positive you have Exclusions set for your wrappers. If all of your portable wrappers have ''Portable'' in their executable name, then an exclusion for ''Portable'' will keep them from being forcefully closed until after TimeToWait seconds have passed. As for making sure settings save, the only way to be sure is to change a setting, use EjectUSB, and then see if the setting change was saved. In the case of Exclusions, TimeToWait is how many seconds an excluded program has to terminate itself, so for portable wrappers, they'd have 30 seconds to save settings and close on their own (with a TimeToWait of 30). If they get done before TimeToWait has passed, EjectUSB just continues on with its next cleanup steps and then ejects.

I do plan to implement absolute exclusions so that EjectUSB won't close a given program under any circumstances, however there should be nothing preventing the current system from working in the way you're wanting (other than it will close PStart). Absolute exclusions will just cause situations where a given program never closes and so ejection never succeeds (which is the primary purpose of EjectUSB), I don't see myself as ever using them personally. That said, they'll likely be implemented in version 1.6.
[ 25 April, 2009 ] • [ William Hedrick ] • [ 12:19:49 ]

Thanks for reply. But it seems, that TimeToWait is just doesn't work. I've tried even TimeToWait=3000, suspecting that it is in ms, but everything is closed in a second.
And the main problem - I launch notepad from target disc, change current document (so it's gonna ask me on closing, if I want to save my document), launch EjectUSB and... everything was closed without any confirmation, so I lost my document.
People, please, check EjectUSB that way before use it.
As I can see, it's common problem, "The only little problem stay to close firefox (portable) ... He think it's a crash at the next start!..." as said Totoche.
So, as I said, "EjectUSB forces applications to close, so that they can't save their settings".
[ 26 April, 2009 ] • [ Dima ] • [ 22:02:17 ]

perfect tools!
You save me from ejecting MSD devices on Vista.
[ 28 April, 2009 ] • [ James Mai ] • [ 02:53:47 ]

Firstly, congratulations for EjectUSB, I use it on my 4 USB keys.

I don't know if it's possible, when the USB key closes, could you include with the drive's name, the name of the USB key?

I ask that because I make a backup from a USB key to another one and I need to know the name of each USB key when closing.

TIA and have a good evening William!
[ 03 May, 2009 ] • [ Marcel Poirier ] • [ 15:44:48 ]

With version 1.5, double clicking on ejectusb.exe on Vista Sp2 32 bit, nothing happens at all.
Nothing at all...
[ 15 May, 2009 ] • [ charlestek ] • [ 06:43:44 ]

Thanks for all "Addition" :-)
[ 17 May, 2009 ] • [ Totoche2607 ] • [ 05:30:42 ]

A success story here: have you heard about Garmin Nuvi GPS units? They mount as a USB volume, and the screen stays on for the duration that it is attached via USB--really stupid of Garmin. Anyway, a post at http://www.fixya.com/suppor... suggested that ejecting worked to turn the screen off while still chargine. But how to do this easily? Hurray for EjectUSB! A script like:

EjectUSB /eject d

is just what I needed on my XP system.

thanks!

larry

BTW, I had no luck with ejectusb working without an argument by running from a folder on the usb drive itself... perhaps I misunderstood those directions.
[ 22 May, 2009 ] • [ larry ] • [ 21:14:21 ]

I would like to see it run from the try with popup menus, the built in windows eject doesn't even give names or sizes, also, How about a right click context menu? Right click on a drive and select ejectusb... anyway thanks for a great program!
[ 24 May, 2009 ] • [ Long.Knight ] • [ 13:22:30 ]

Can't support playing Video with USB.
[ 26 May, 2009 ] • [ scavin ] • [ 10:47:47 ]

FYI, I couldn't get it to work either. Tried all the suggestions above. I'm on a simple XP system. Using the safely remove hardware works very quickly on my system. Running from c:ejectUSB.exe /eject h: leaves the icon in the tray forever. Too bad. i really wanted this to work.
[ 04 June, 2009 ] • [ Ray Barbieri ] • [ 15:18:59 ]

If you are having trouble here, try this: ftp://ftp.heise.de/pub/ct/l...
[ 04 June, 2009 ] • [ Ray Barbieri ] • [ 15:31:25 ]

Your download has a virus generic worm in it and the .exe has to be deleted. I liked the program but can't use it if 3 different virus checkers find it contaminated!!
[ 12 June, 2009 ] • [ paladin ] • [ 16:41:51 ]

I'm also getting a virus detection (Worm/Generic.ABWH) in AVG Free. =\
[ 12 June, 2009 ] • [ TN ] • [ 17:28:12 ]

I too am having AVG detect a worm in this program. I have uninstalled it from my machine until there is some kind of explanation from the author. Same as user above, Worm/Generic.ABWH

It could be a false positive, or then it could be a real worm. Nobody should install or use this program until this worm or false positive is addressed by the program's author.
[ 12 June, 2009 ] • [ K. Foster ] • [ 19:33:10 ]

My AVG Detect Version 1.5 As "Worm/Generic.ABWH"
[ 13 June, 2009 ] • [ Ravindra Chauhan ] • [ 01:23:45 ]

It's a false positive; the source is available for download above. You can download AutoIt3 and rebuild the executable yourself if you're paranoid. I'll submit a report to AVG (I've had trouble with them and false positives before) when I am able.
[ 13 June, 2009 ] • [ William Hedrick ] • [ 04:39:35 ]

Can't get this to actually do anything. I'm running WindowsXP. The drive is a Western Digital 80GB harddrive.
It does close all open processes though. That's a nice bonus. Probably just use it for that functionality alone.
[ 19 June, 2009 ] • [ CottonEyeJoe ] • [ 07:52:03 ]

I'm having a problem trying to get EjectUSB quit some on-board apps then eject. Specifically the problem I have is with Portable Firefox. I usually have multiple browser windows open with multiple tabs, and when I fire off EjectUSB it looks like it's trying to close each window individually, with the resulting "This window has multiple tabs, are you sure?" dialog popping up for each window. First up, even if this worked, it would stop me being able to do a full session restore on restart, as only the final window to be closed would register as the session closing, and more importantly, it looks like EjectUSB is continually trying to fire off the Close Window for each window, so that I'm never able to actually hit the confirmation button on the warning dialogs.
Any thoughts on a solution or workaround?
[ 26 June, 2009 ] • [ Endareth ] • [ 00:43:48 ]

r r r
[ 28 June, 2009 ] • [ 7397wq ] • [ 09:48:30 ]

working great on Vista 32. Successfully ejected a USB HDD that windows and 'USB Safely Remove' could not.

I sure wish I could run this at startup and have it sit in the minimized window waiting for use for a simple click and select drive to remove.
[ 29 June, 2009 ] • [ Jeff ] • [ 12:13:52 ]

Add Comment