2014年3月21日 星期五

Disable USB mà không ảnh hưởng đến Mouse và Keyboard

****************************
@echo off
:: Retreive Windows Language
:detect
for /f "Skip=1 Tokens=3*" %%i in ('reg QUERY "hklm\system\controlset001\control\nls\language" /v Installlanguage') do set language=%%i

:: Dutch - Belgium
if "%language%" == "0813" (
set users=Gebruikers
goto select
)
:: Dutch - Netherlands
if "%language%" == "0413" (
set users=Gebruikers
goto select
)
:: English - United States
if "%language%" == "0409" (
set users=Users
goto select
)

:select
if /I "%1" == "enable" goto enable_usbstor
if /I "%1" == "disable" goto disable_usbstor

echo Invalid commandline options
echo.
echo %0 - Enable or disable USB mass storage
echo %0 enable - enable USB mass storage
echo %0 disable - disable USB mass storage
exit /b 1

:enable_usbstor
echo Enabling USBstor driver
:: Enable USBstor driver
reg add HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR /v Start /t REG_DWORD /d 3 /f
:: Enable permissions on USBstor driver
cacls %SystemRoot%\inf\usbstor.inf /E /G %users%:R
cacls %SystemRoot%\inf\usbstor.PNF /E /G %users%:R
:: Leave state for WPKG to check on
if exist %SystemRoot%\usbstor-disable.tmp del %SystemRoot%\usbstor-disable.tmp
echo enable > %SystemRoot%\usbstor-enable.tmp
goto end

:disable_usbstor
echo Disabling USBstor driver
:: Disable USBstor driver
reg add HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR /v Start /t REG_DWORD /d 4 /f
:: Disable read permissions on USBstor driver
cacls %SystemRoot%\inf\usbstor.inf /E /R %users%
cacls %SystemRoot%\inf\usbstor.PNF /E /R %users%
:: Leave state for WPKG to check on
if exist %SystemRoot%\usbstor-enable.tmp del %SystemRoot%\usbstor-enable.tmp
echo disable > %SystemRoot%\usbstor-disable.tmp
goto end

:end
exit /b 0


**************************************

沒有留言:

張貼留言