@echo off

REM   WHAT DOES THIS BATCH FILE DO?
REM   -----------------------------
REM   There is a virus that transfers itself to flash drives, so it can attempt 
REM   to infect every computer you insert the infected flash drive into.  The 
REM   virus uses a FOLDER named RECYCLER, and a TEXT FILE named autorun.inf 
REM   
REM   KILLAUTORUN.BAT attempts to remove both the above mentioned folder and 
REM   text file. If it can successfully delete them, it then replaces them in a 
REM   way that prevents the virus from reinfecting the flash drive.
REM   
REM   To do this, a FOLDER with the name autorun.inf (instead of a TEXT FILE 
REM   of the same name, as before) is created.  Likewise, a TEXT FILE named 
REM   RECYCLER (instead of a FOLDER of the same name, as before) is also 
REM   created.  Since there can't be a file and a folder of the exact same name 
REM   in the same folder, this stops the virus from being able to do what it
REM   tries to do.  This does not get rid of the virus if it is on your main 
REM   system though.  It just prevents the virus from transferring to your flash 
REM   drives again, as long as you do the below to all of your flash drives.
REM   
REM   INSTRUCTIONS:
REM   -------------
REM   Put this file ( KillAutorun.bat ) into the root of the flash drive (not in 
REM   a folder), then double click it to run it. If either the autorun.inf file, 
REM   or the RECYCLER folder will not allow access, you need to first backup all 
REM   the files on the flash drive, format the flash drive, then put your files 
REM   back on after the format is complete. If you have to format the flash drive, 
REM   make sure to RUN THIS BATCH FILE FROM THE ROOT of the flash drive RIGHT 
REM   AFTER FORMATTING IT, so you don't give the virus a chance to infect the 
REM   flash drive again.
REM
REM   Last Updated: September 24, 2012
REM   
REM   Tom ( noyou22@yahoo.com )

cls
echo.
if "%1"=="reset" goto RESET
if not exist RECYCLER goto MAKE_RECYCLER_FILE

:DEL_RECYCLER_FOLDER
echo Deleting the RECYCLER folder (if it exists)...
attrib -r -s -h RECYCLER /s /d
rd RECYCLER /s /q

:MAKE_RECYCLER_FILE
echo.
echo Creating the RECYCLER file, and making it read only and hidden...
echo > RECYCLER
attrib +r +h RECYCLER

:DEL_AUTORUN_FILE
if not exist autorun.inf goto MAKE_AUTORUN_FOLDER
echo.
echo Deleting the AUTORUN.INF file...
attrib -r -s -h autorun.inf
del autorun.inf /q 

:MAKE_AUTORUN_FOLDER
if exist AUTORUN.INF\*. goto MOVE_BATCH_FILE
echo.
echo Creating the AUTORUN.INF folder, and making it read only and hidden...
md autorun.inf
attrib +r +s +h autorun.inf

:MOVE_BATCH_FILE
echo.
echo Moving KillAutorun.bat & KAReadMe.txt to the newly created autorun.inf folder...
@ copy KillAutorun.bat \autorun.inf\ >> NUL
@ copy KAReadMe.txt \autorun.inf\ >> NUL
goto END

:RESET
attrib -r -s -h autorun.inf
rd autorun.inf /S /Q
echo > autorun.inf
attrib -r -s -h RECYCLER
del RECYCLER
md RECYCLER
goto END

:END
echo.
echo Finished!
echo.
pause
echo.
echo If a message appears below, ignore it.  Either way, no worries :)
echo.
if "%1"=="" del KillAutorun.bat >> NUL
    

RIGHT CLICK HERE to download KillAutorun.bat