Tuesday, December 27, 2011

Disable USB Storage Using Regedit


There is a simple registry change that will keep the USB storage drivers from starting when the system boots. Keeps people from walking up to a PC and copying data off with a USB storage or pendrive, but allows you to keep your scanner, keyboard, and mouse in working 

state.HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor




Notice the value ‘Start‘

Switch this value to 4, and USB storage devices are disabled.
Switch this value to 3, and USB storage devices are enabled
Another procedure is :copy these text in to the notepad then save it as a .bat extension(Like: example.bat)

@ECHO off
cls
:start
ECHO Press: 1 - to Enable USB storage device.
ECHO Press: 0 - to Disable USB storage device.
ECHO.
set choice=
set /p choice=What is your choice [1,0]?
if not '%choice%'=='' set choice=%choice:~0,1%
if [%choice%]==[1] goto enable
if [%choice%]==[0] goto disable
ECHO "%choice%" is not a valid option. Please try again...
ECHO.
goto start
:enable
:: Create a temporary .REG file - ENABLE USB
> "%Temp%.\EnableUSBStor.reg" ECHO REGEDIT4
>>"%Temp%.\EnableUSBStor.reg" ECHO.
>>"%Temp%.\EnableUSBStor.reg" ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR]
>>"%Temp%.\EnableUSBStor.reg" ECHO "Start"=dword:00000003
:: Rename the following two files to ENABLE USB storage device on the computer
rename %SystemRoot%\Inf\Usbstor.pnf.fisha Usbstor.pnf
rename %SystemRoot%\Inf\Usbstor.inf.fisha Usbstor.inf
START /wait regedit /s "%Temp%.\EnableUSBStor.reg"
DEL "%Temp%.\EnableUSBStor.reg"
ECHO.
ECHO Successfully ENABLE USB storage device on this computer.
PAUSE
GOTO end
:disable
:: Create a temporary .REG file - DISABLE USB
> "%Temp%.\DisableUSBStor.reg" ECHO REGEDIT4
>>"%Temp%.\DisableUSBStor.reg" ECHO.
>>"%Temp%.\DisableUSBStor.reg" ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR]
>>"%Temp%.\DisableUSBStor.reg" ECHO "Start"=dword:00000004
:: Rename the following two files to DISABLE USB storage device on the computer
rename %SystemRoot%\Inf\Usbstor.pnf Usbstor.pnf.fisha
rename %SystemRoot%\Inf\Usbstor.inf Usbstor.inf.fisha
START /wait regedit /s "%Temp%.\DisableUSBStor.reg"
DEL "%Temp%.\DisableUSBStor.reg"
ECHO.
ECHO Successfully DISABLE USB storage device on this computer.
PAUSE
GOTO end
:end