You are here

Eject Thumb Drive - No matter what drive letter

1 post / 0 new
DarkCyber
Offline
Last seen: 16 years 8 months ago
Joined: 2007-08-05 08:32
Eject Thumb Drive - No matter what drive letter

Eject Thumb Drive - No matter what drive letter

Reading english no problem but writing.

I did't no where to post it, this looks like the rith place.

Tested on windows xp

Needed tools:

sync.exe
wait.exe

http://www.microsoft.com/technet/sysinternals/FileAndDisk/PsTools.mspx
http://www.ppedv.de/dwnld/wait.zip

First Batch file "Launch.bat":

title Eject Drive
if not exist "NoCleanup.txt" echo Got to protect yourself from yourself >"Nocleanup.txt"

rem Take out the trash you forgot, shame on you
if exist "%USERPROFILE%\Local Settings\Temp\Eject Drive.bat" del "%USERPROFILE%\Local Settings\Temp\Eject Drive.bat"
if exist "%USERPROFILE%\Local Settings\Temp\wait.exe" del "%USERPROFILE%\Local Settings\Temp\wait.exe"
if exist "%USERPROFILE%\Local Settings\Temp\sync.exe" del "%USERPROFILE%\Local Settings\Temp\sync.exe"
if exist "%USERPROFILE%\Local Settings\Temp\cleanup.bat" del "%USERPROFILE%\Local Settings\Temp\cleanup.bat"

copy "Eject Drive.bat" "%USERPROFILE%\Local Settings\Temp\" >"%USERPROFILE%\Local Settings\Temp\0"
copy sync.exe "%USERPROFILE%\Local Settings\Temp\" >"%USERPROFILE%\Local Settings\Temp\0"
copy wait.exe "%USERPROFILE%\Local Settings\Temp\" >"%USERPROFILE%\Local Settings\Temp\0"

rem Get concurrent drive
cd\
set drive=%cd%

cd /d "%USERPROFILE%\Local Settings\Temp\"
"Eject Drive.bat"
:End

Sec Batch File "Eject Drive.bat":

@echo off
title Eject Drive
echo Ejecting Drive.........Wait

rem The Cleanup Guy
echo @echo off >>cleanup.bat
echo if exist "nocleanup.txt" exit >>cleanup.bat
echo del "Eject Drive.bat" >>cleanup.bat
echo del sync.exe >>cleanup.bat
echo del wait.exe >>cleanup.bat
echo del 0 >>cleanup.bat
echo del cleanup.bat >>cleanup.bat

rem If no app is hooking the drive it shoot pop out
sync.exe -e -r %drive%
set drive=
wait 1
cleanup.bat
:End