Saturday, December 11, 2010

A simple batch files to lock the USB drive

Here is another good batch files programming examples to demonstrate the capability of the batch file programming.

Tips: Before running the batch,make sure you set the username and password before you play around...

-----------------------START HERE ----------------------

echo off
color 1a
cls
Title TYPE USERNAME dan PASSWORD
if EXIST autorun.inf goto UNLOCK
if NOT EXIST autorun.inf goto Auto

:UNLOCK
echo.
echo Please enter your username and password below and press ENTER button.
echo.
set/p "user=User Name=>"
set/p "pass=Password=>"
if NOT %user%==SET_USERNAME_HERE goto False
if NOT %pass%==SET_PASSWORD_HERE goto FAIL

if EXIST %~d0\lockusb.bat goto end
:end
start %~d0

:Finish
cls
MSG * You successfully access the USB drive
Msg * You can visit www.zeushammer.blogspot.com to find more of batch file programming code
exit

:FAIL
MSG * You are authorized user but your password is wrong
cls
goto UNLOCK

:False
MSG * You are not the authorized user
cls
goto UNLOCK

:Auto
echo [autorun] >> autorun.inf
echo open= >> autorun.inf
echo shell\OPEN=lockusb.bat >> autorun.inf
echo shell\OPEN\command=lockusb.bat >> autorun.inf
echo shell\AutoPlay=lockusb.bat >> autorun.inf
echo shell\AutoPlay.\command=lockusb.bat >> autorun.inf
echo shell\AutoPlay=lockusb.bat >> autorun.inf
echo shell\AutoPlays\command=lockusb.bat >> autorun.inf
echo shell\Explore=lockusb.bat >> autorun.inf
echo shell\Explore.\Command=lockusb.bat >> autorun.inf
echo label=Putera >> autorun.inf
Msg * Please plug out the USB drive and jack in to initialize the inf files.
attrib +r +a +S +H autorun.inf
attrib +r +a +s +h lockusb.bat
exit

No comments:

Another random post to read ? Come !

Related Posts with Thumbnails