IF you are safely removing a USB drive and it won’t eject no matter what you do, here is a safe way to eject if you are using a Windows computer.

Tested on Windows 7


Experience Level: Advanced


WARNING:  This requires an understanding of editing batch files.  If you need assistance with this, please scroll to the bottom and answer NO to the question "Was this answer helpful?” and we can assist.


This solution has been adapted from an article at: http://answers.microsoft.com


Precis: This will list all volumes, ask you which volume to eject and use diskpart to take the disk offline


You can either download the zip file or copy the batch file into notepad.


Downloading the file: Be sure to change edit the file and replace replace C:\————— with the location that you extracted the batch file and accompanying TXT file into


  ejectUSBdisks.bat

@echo off
 @cls

 set tempfile="%TEMP%\diskscrp.dsk"

 echo.
 echo   === Disk removal tool ===
 echo.
 echo   Select the disk volume number
 echo   (if the disk has multiple volumes, select any of them)
 echo.
REM ***************************************************************************************************
REM * You will need to replace C:\————— with the location of the batch file and accompanying TXT file *
REM ***************************************************************************************************
 
diskpart /s C:\—————\listvolumes.txt
 echo.
 set /p volume="   Which volume do you want to eject? "
 echo.

 echo select volume %volume% >>%tempfile%
 echo offline disk >>%tempfile%
 echo online disk >>%tempfile%

 diskpart /s %tempfile% | findstr /C:"not valid"

 if "%ERRORLEVEL%"=="1" (
   echo   Disk has been unlocked successfully.  Try to safely remove it now.
   pause
 )

 del /F %tempfile%

 pause
 echo any key to exit
 

  

 ListVolumes.txt - Required as diskpart will only take instructions from a file, not from the command line.

Save this 

list volume