最近公司领导要求客服那边部分电脑禁用USB设备,如U盘等,但是还得保证鼠标和键盘能用,经过一番研究,脚本如下:

关闭过程:
@echo off
reg add "HKEY_LOCAL_ MACHINESYSTEMCurrentControlSet ControlStorageDevicePolicies“ /v WriteProtect /t reg_dword /d 1 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f
copy %Windir%\inf\usbstor.inf %Windir%\usbstor.inf /y >nul
copy %Windir%\inf\usbstor.pnf %Windir%\usbstor.pnf /y >nul
del %Windir%\inf\usbstor.pnf /q/f >nul
del %Windir%\inf\usbstor.inf /q/f >nul
@echo on
开启过程:
@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 3 /f
copy %Windir%\usbstor.inf %Windir%\inf\usbstor.inf /y >nul
copy %Windir%\usbstor.pnf %Windir%\inf\usbstor.pnf /y >nul
del %Windir%\usbstor.pnf /q/f >nul
del %Windir%\usbstor.inf /q/f >nul
@echo on
将以上代码保存为两个BAT文档,然后放进x:\Windows\system32\目录下,比如DisableUSB.bat和EnableUSB.bat
然后直接在运行里面输入指令:DisableUSB (关闭)EnableUSB(开启)