New in this version
Added: /CFGDIR command line switch - this lets you specify a different location for the cfg file that stores all the settings. Normally this file is located in the same directory as the program but some people wanted a way to change this.
What is USB Disk Ejector?
A program that allows you to quickly remove drives in Windows. It can eject USB disks, Firewire disks and memory cards. It is a quick, flexible, portable alternative to using Windows' "Safely Remove Hardware" dialog.
It will work on any version of Windows from XP onwards, that includes:
- Windows XP
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
- Windows Server versions from 2003 onwards are untested by me but have been reported to work.
- 32 bit and 64 bit versions of all the above
What makes this so useful?
It is quick. Rather than clicking through the "Safely Remove Hardware" dialog you can very quickly remove drives or card media. You can even create shortcuts or hotkeys to eject a drive.
It is simple. The program is designed to be easy to use and its advanced options are hidden so that they dont get in the way.
It is portable. It can be stored and used on a removable device like a pen drive. It can even eject the disk that it is running from. It doesnt require administrator rights and doesnt need installing.
It is flexible. There are many features that can be customised such as hotkeys, positioning, notifications and post-eject actions.
It can be run as a command line program. The command line options are very flexible, they can be used to:
- Eject the drive that the program is running from.
- Eject a drive by specifying a drive letter.
- Eject a drive by specifying a drive name.
- Eject a drive by specifying a mountpoint
- Eject a drive by specifying a partial drive name.
So you could setup a hotkey, desktop shortcut or bat file to eject a drive. Or if you use a menu such as PStart or the Portable Apps launcher you could use the command line switches so that with one click the menu will exit, the program will run and the drive will be ejected. See the 'Command Line' section below for more information.
It can eject disks when Vista cant. In Vista, disks often cant be ejected because they have an open explorer window. Other versions of Windows will close any explorer windows belonging to a disk but Vista often doesnt - so USB Disk Ejector closes does it before ejecting.
It can eject disks when Windows sometimes cant. If any applications are running from a disk then Windows wont be able to eject it. USB Disk Ejector can detect and auto-close any applications running from the disk before ejecting. Please note this closes applications that were launched from the disk not applications that have opened a file on the disk. See the limitations section further down for more information.
It is small. Less than 1.5MB (when UPX compressed).
It is open source. All source code can be found on my Github.
What do I need to use this?
A removable USB or Firewire device such as a flash drive, digital camera or external hard drive. Any USB or Firewire device that shows as a disk should be removable by this.
For ejecting card media - such as flash memory cards any internal or external card reader should work.
Using the program
- Load the program, if you have any removable USB/Firewire drives or memory cards they will be shown in the list.
- If you plug in any additional devices while the program is running then the list will automatically update to show them.
- Double click on a device to remove it.
- Unplug the device from your computer.
More features:
- Double right clicking on a drive opens an explorer window for that disk
- Drives mounted in a folder like this are also supported.
- If your card reader is shown as a drive not a card reader then you can change this. In options go to the Card Readers tab. There you can define a particular drive as a card reader, it will then be treated and shown as a card reader.
- The program has a system tray icon - you can right click this to eject disks. This is similar to the behaviour of the Windows "Safely Remove Hardware" tray icon.
- Settings are saved in a file called USB_Disk_Eject.cfg - but this wont be created unless you change a setting in the options. It will always be saved into the same place as the program itself.
- If you have a disk that has multiple drives (eg a hard drive with multiple partitions) then this can be set to only show one entry in the program. To enable this tick "show drives with partitions as one entry" in the options. If you enable this option then hovering your mouse over the disk will being up a tooltip showing what disks 'belong' to that entry.
- There are many more features - click on "More" and go to "Options" to see the full list.
Command Line
When using the program on the command line, settings that have been created when using the program normally may still be used. If USB_Disk_Eject.cfg is found in the same folder as the program then it will read and use settings from it. Settings such as removal notifications will be dictated by what has been set in options if this file is present.
This is particularly important when dealing with memory cards and card readers. For example if a device has been defined as a card reader in options then when ejecting the program will honor this and eject the card media not the card reader device.
If you dont want the program to inherit options then make sure that USB_Disk_Eject.cfg is not present in the same folder.
The following command line options are available:
- /?
Displays a dialog that shows all command line options. - /NOSAVE
Settings are not saved, no cfg file will be created. But if theres USB_Disk_Eject.cfg in the same place as the program, options will be read from it. Use this if you want to launch the program but stop it saving settings or overwriting existing settings. - /CFGDIR
Specify a different path for the cfg file (the file where settings are stored). EG /CFGDIR "c:\users\ben\desktop\stuff" - /REMOVETHIS
Ejects the drive that the program is running from. Eg if the program is run from a usb stick on drive G then drive G would be ejected. - /REMOVELETTER
Ejects the specified drive letter. Eg /REMOVELETTER G - /REMOVEMOUNTPOINT
Ejects the specified mountpoint. Eg /REMOVEMOUNTPOINT "C:\Test USB Disk Mount" - /REMOVENAME
Ejects the drive with the specified name. Eg /REMOVEDRIVE "Sandisk U3 Titanium"
Partial name matching is possible if a wildcard (*) is used. Eg /REMOVENAME "*SANDISK" would eject a drive that had Sandisk in its name. - /REMOVELABEL
Ejects the drive with the specified label. Eg /REMOVLABEL "Work Drive"
Partial name matching is possible if a wildcard (*) is used. Eg /REMOVELABEL "*BEN" would eject a drive that had Ben in its label (eg Ben's Pen Drive).
- /EJECTCARD
Ejects the card media from a drive rather than trying to eject the drive itself.
Combine it with other switches Eg /REMOVELETTER G /EJECTCARD would eject an SD card in drive G.
The command line switches could be used to eject a drive from the command prompt, a bat file, a desktop shortcut or as part of a script or menu.
Upgrading From Previous Versions (before v1.3)
If you are upgrading from a version before 1.3 then be aware that some command line switches have been removed:
- /SILENT
- /SHOWEJECT
- /CLOSEAPPS
- /CLOSEAPPSFORCE
These settings are now set in the options menu. If you are using the program from the command line and USB_Disk_Eject.cfg is found in the same folder as the program then it will read and use settings from it. If its not found then the default settings will be used.
Using these switches with this new version of the program wont cause any problems - they will just be ignored.
Limitations/Bugs
Please contact me or create an issue on Github if you spot any bugs or problems that arent listed below.
- If you have balloon tips turned on in Windows XP then Windows shows a balloon tip when a device is removed ("device x can now be safely removed from the system"). If you remove one device and then try to remove another, the second device will not be removed until you close the balloon tip. If this irritates you, then you can try disabling balloon tips altogether. See this link for information on how to do this.
- A disk eject can fail when there is still an application or process accessing the drive.
If the application that is accessing the drive is running from the drive that you're trying to eject then USB Disk Ejector can detect this and close it (see the options menu to enable this). Eg if you launch Portable Firefox from a USB flash drive and then try and eject that flash drive then USB Disk Ejector will close Portable Firefox and then successfully eject the drive.
If the program accessing the disk is one installed on your computer (eg if Microsoft Word has opened a document on a flash drive that you are trying to eject) - then USB Disk Ejector wont be able to detect this and wont be able to close it. Doing this reliably requires administrator rights and a kernel driver - something beyond the scope of this program.
You may be able to use Process Explorer or Unlocker to find and stop whatever program or process is accessing a drive.
Acknowledgements And Thanks
- Ejection code is based upon C code by Uwe_Sieber.
- Ipod icon unknown - please contact me if you are/know the author.
- Options unit based on code by Sebastián Mayorá
- Program and drive icon is from the Snow.E2 set by Sascha Höhne.
- Uses the Jedi Code Library and the JEDI Setup and Config Manager API
Uses PNG ImageList by Martijn Saly
- Uses Virtual Treeview by Mike Lischke (and others)
Disclaimer
The software is provided "as-is" and without warranty of any kind, express, implied or otherwise, including without limitation, any warranty of merchantability or fitness for a particular purpose. In no event shall the initial developer or any other contributor be liable for any special, incidental, indirect or consequential damages of any kind, or any damages whatsoever resulting from loss of use, data or profits, whether or not advised of the possibility of damage, and on any theory of liability, arising out of or in connection with the use or performance of this software.
Support
Contact me.
All my software is completely free. If you find this program useful please consider making a donation. This can be done on my website.
Changelogs for previous versions:
New in version 1.3.0.5
Added: /EJECTCARD command line switch - this makes it eject the card media rather than the drive itself. Combine it with other switches Eg /REMOVELETTER G /EJECTCARD would eject an SD card in drive G
Changed: The 'Bring to front/restore' hotkey now toggles between hiding/showing the program.
Fixed: Card readers with identical drives like Kingston MobileLite G4. Previously you could only set one drive as a card reader - now if you define one as a card reader both become card readers.
Fixed: Pressing escape to minimize didnt work when 'minimize to tray' was disabled.
Fixed: Memory card ejection via hotkeys. Previously ejecting via a hotkey just ejected the drive regardless of whether it was a card reader or not. Now it behaves like the rest of the program - if it is a card reader then the media is ejected rather than the drive.
Fixed: Memory card ejection when the program is in 'mobile mode' - this is when it copies and restarts itself eg when trying to eject the drive the program is running from. Card reader settings are now respected here - if it is a card reader then the media is ejected rather than the drive.
New in version 1.3.0.4
Added option to use the escape key to minimize the window.
Fixed problem with some rare drives that dont have a mountpoint. These cant be ejected in the usual way and indeed dont show up in windows' own safely remove dialog. Drives like these are no longer shown in the program.
Stopped compressing with UPX. The exe is now 4MB in size instead of 1.5MB but it means that it uses half the memory which is a worthwhile tradeoff.
New in version 1.3.0.3
Fixed rare bug that could prevent custom card readers from being identified as a card reader when the program was first run.
New in version 1.3.0.1 and 1.3.0.2
Fixed tooltip bug that slipped through testing - if you hovered the mouse over the program when there was no drives inserted it would create an error. Many thanks to Bruce Lightfoot for spotting this.
Improved error reporting, if a disk cant be ejected now - it should give a more appropriate response. (If a disk cant be ejected 99% of the time the reason is that a file or process is using the disk).
New in version 1.3.0
There's been a huge number of changes since the last stable version. Most elements of the program have been rewritten. Many bugs have been fixed and there are some significant new features. The most important ones are listed below:
- Full card reader and memory card support. You can now eject media, show/hide card readers, hide empty card readers and even define drives as card readers.
- Mountpoint support. All detection and ejecting is done using mountpoints rather than drive letters, this means that drives mounted in a folder like this are supported.
- Options window added - options can now be easily set and saved. There are now many settings that can be configured and customised.
- Much better notifications:
- Uses balloon hints in the taskbar for notifications instead of a messagebox
- Much better detection and explanation of the reasons for a failed eject
- Now notifies (via a balloon hint) when an eject is successful
- Support for Firewire disks.
- Big changes to drive detection and ejection code - stops the freezing that could sometimes happen with the old version when trying to eject some types of drive.
Full changelog for v 1.3.0:
- Support for Firewire drives/disks
- Support for card readers/flash memory cards (Cards are now ejected not the card reader as happened in previous versions)
- Auto-polling to detect when a new flash card is inserted (windows doesn't do this)
- Double right clicking on a drive opens an explorer window for the disk
- Much better notifications:
- Uses balloon hints in the taskbar for notifications instead of a messagebox
- Much better detection and explanation of the reasons for a failed eject
- Now notifies (via a balloon hint) when an eject is successful
- Automatically closes explorer windows related to the disk before ejecting (this stops a lot of the failed ejects in Vista)
- Can auto-close any applications running from the disk before ejection:
- Can do this using a safe 'ask' method or a brute force unsafe method
- Please note this closes applications that were launched from the ejecting disk. It currently does not close applications launched from elsewhere that have a file from the ejecting drive open.
- Eg - if you launch portable firefox from a usb stick and then eject the stick it should close portable firefox and eject successfully, but if you open a document on the pen drive in Word then it wouldnt be able to detect and close this.
- Hotkey support (can assign a hotkey to eject a drive based on its name or drive letter)
- New 'no disks' found icon - the old face icon apparently scared some people
- Added tray icon:
- Added popup menu to tray icon so you can right click and eject disks, similar to the behaviour of Windows' 'Safely remove hardware' tray icon
- Smart auto-resizing of the program window to accommodate new disks/devices
- Better docking behaviour when the program window is in a corner of the screen
- Added '/NOSAVE', '/CLOSEAPPS' and '/CLOSEAPPSFORCE' command line switches
- Fixed - font size in the options dialog on Windows XP
- Fixed - very rarely a device with many disks/partitions might not have all its disks detected correctly. The detection procedure is now threaded to stop this rare occurance
- Fixed - if the program was set to read only - when it restarted in mobile mode and copied to the temp folder it couldnt delete itself
- Options dialog added - options can now be set and saved. Click on 'more' then 'options' to show it.
- Added options to:
- Start the program minimized
- Remember the last size of the program window
- Remember the last position of the program window
- Autosize the program window
- Enable/disable balloon notifications
- Close to the system tray
- Minimize to the system tray
- Enable/disable eject notifications
- Use the standard windows eject notifications
- Close the program after a successful ejection
- Minimize the program after a successful ejection
- Control the adding and management of hotkeys
- Control the closure of any programs running from a drive before ejection
- Search for media cards (in card readers)
- And much more...
- Threads - stop very rare issue where device with many partitions or card reader device supporting multiple devices - not all drives were detected
- Card readers - specify which ones are readers in options - match by various fields
- Option to hide card readers with no media in
- Option to set card polling time - default is 5 seconds
- Option to hide all card readers
- Option to show drives with multiple partitions as one entry - with different icon to indicate this
- Option to set max width of form - useful eg if mountpoint in a deeply nested folder
- Fixed - problem with commandline - if drive letter called as lower case ExtractFilePath - would pass the letter as lower case
- Fixed - EmumWindows - problem - explorer windows are now closed successfully again
- Fixed - Ejecting mountpoint from command line - case mattered - even when doing /REMOVETHIS - now looks up the correctly cased mountpoint name
- Fixed - quotes around params when restarting in mobile mode
- Fixed - /REMOVELETTER not restarting in mobile mode when attempting to eject self
- Fixed - EnumWindowAndClose and CloseAppsRunningFrom - now take into account partitions on same drive
- Fixed - Clearer error codes - shows the code if reason for a failed eject is unknown (and not 0)
- Threads - stop very rare issue where device with many partitions or card reader device supporting multiple devices - not all drives were detected
- Card readers - specify which ones are readers in options - match by various fields
- Option to hide card readers with no media in
- Option to set card polling time - default is 5 seconds
- Option to hide all card readers
- Option to show drives with multiple partitions as one entry - with different icon to indicate this
- Option to set max width of form - useful eg if mountpoint in a deeply nested folder
- Fixed - problem with commandline - if drive letter called as lower case ExtractFilePath - would pass the letter as lower case
- Fixed - EmumWindows - problem - explorer windows are now closed successfully again
- Fixed - Ejecting mountpoint from command line - case mattered - even when doing /REMOVETHIS - now looks up the correctly cased mountpoint name
- Fixed - quotes around params when restarting in mobile mode
- Fixed - /REMOVELETTER not restarting in mobile mode when attempting to eject self
- Fixed - EnumWindowAndClose and CloseAppsRunningFrom - now take into account partitions on same drive
- Fixed - Clearer error codes - shows a code if reason for a failed eject is unknown (and not 0)