Created
November 8, 2022 14:56
-
-
Save IamFaizanKhalid/f3cfb8bd1028c79f71efc829ee3a0c54 to your computer and use it in GitHub Desktop.
Protect USB drive from AutoRun virus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo This will create an undeletable folder AUTORUN.INF and a file RECYCLER on | |
echo the drive you choose in next prompt. | |
echo. | |
echo 1. Enable | |
echo 2. Disable (Undo this tweak) | |
echo 3. Exit | |
echo. | |
set /p twk=Choose an option : | |
if "%twk%"=="1" goto d | |
if "%twk%"=="2" goto d | |
exit | |
:d | |
set /p usbdr=Now Choose the Drive (eg. E) : | |
if not exist %usbdr%:\nul echo Invalid Drive %usbdr%:\ | |
if not exist %usbdr%:\nul goto d | |
if "%twk%"=="1" goto m | |
if "%twk%"=="2" goto r | |
exit | |
:m | |
if exist %usbdr%:\Recycler\nul rmdir /s /q \\.\\%usbdr%:\Recycler | |
if exist %usbdr%:\Recycler del /f /q /a %usbdr%:\Recycler | |
echo Faizan Khalid> %usbdr%:\Recycler | |
attrib %usbdr%:\Recycler +r +s +h | |
if exist %usbdr%:\$Recycle.Bin\nul rmdir /s /q \\.\\%usbdr%:\$Recycle.Bin | |
if exist %usbdr%:\$Recycle.Bin del /f /q /a %usbdr%:\$Recycle.Bin | |
echo Faizan Khalid> %usbdr%:\$Recycle.Bin | |
attrib %usbdr%:\$Recycle.Bin +r +s +h | |
if exist %usbdr%:\Recycled\nul rmdir /s /q \\.\\%usbdr%:\Recycled | |
if exist %usbdr%:\Recycled del /f /q /a %usbdr%:\Recycled | |
echo Faizan Khalid> %usbdr%:\Recycled | |
attrib %usbdr%:\Recycled +r +s +h | |
if exist %usbdr%:\Autorun.inf del /f /q /a %usbdr%:\Autorun.inf | |
mkdir \\.\\%usbdr%:\Autorun.inf\nul.FaizanKhalid | |
attrib %usbdr%:\Autorun.inf +s +h | |
echo Folder %usbdr%:\AUTORUN.INF and File RECYCLER created | |
goto x | |
:r | |
rmdir /s /q \\.\\%usbdr%:\Autorun.inf | |
del /f /q /a %usbdr%:\Recycled | |
del /f /q /a %usbdr%:\Recycler | |
del /f /q /a %usbdr%:\$Recycle.Bin | |
echo Folder %usbdr%:\AUTORUN.INF and RECYCLER Files removed | |
:x | |
set usbdr= | |
echo. | |
echo Press any key to EXIT | |
pause>nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment