My Blog List

Wednesday, 1 August 2012

How to Write Protect a USB Flash Drive


How to Write Protect a USB Flash Drive 

If you want to write protect your USB drive, you can do it with the given registry trick or batch script. Protecting USB drive depends on Registry, and you can do it manually or by the script. Read below. Mannual way is also given along with batch script

Manually:
1- Start > Run > type “regedit” to open regisry editor
2- Navigate to this: HKey_LOCAL_MACHINESystemCurrentControlSetControl
3- Create a new key with the name “StorageDevicePolicies”
4- On the right side, Create a new “DWORD Value” with thr name “WriteProtect” and give it “1" as Data
5- Then put the USB Flash Drive.
6- Try to Delete a file Or Copy something to it, You will not be able to do that.
7- To disable this feature, just change the data from 1 To 0

The Batch Script :


::-----------------------------------------::
:: Name: USB Flash Drive Write Protect.bat ::
::-----------------------------------------::
:main
@echo off
cls
echo. & echo. & echo.
echo  USB Write Protect program
echo ________________________________
echo. & echo.
echo     1. Lock the USB Flash Drive
echo     2. UnLock the USB Flash Drive
echo     3. Exit
echo.
set/p "ch= [>] Enter: "
if %ch%==1 goto lock
if %ch%==2 goto unlock
if %ch%==3 goto exit
goto main
:lock
cls
echo. & echo. & echo.
echo [+] Attention:
echo.
echo     Make sure that there is no USB Flash Drives inserted.
echo.
echo -----------------------------------------------------------
pause
reg add HKLMsystemcurrentcontrolsetcontrolStorageDevicePolicies /t reg_dword /v writeprotect /d 1 /f
pause > nul
goto main
:unlock
cls
echo. & echo. & echo.
echo. & echo. & echo.
echo [+] Attention:
echo.
echo     This operation doesn't require to Unplug the USB Flash Frive,
echo     so Continue without FEAR.
echo.
echo -------------------------------------------------------------------
pause
reg add HKLMsystemcurrentcontrolsetcontrolStorageDevicePolicies /t reg_dword /v writeprotect /d 0 /f
pause > nul
goto main

Hope it’s Useful and help You