寫過2個批處理做這個封USB,一個關閉,一個開啟。統一分發關閉。需要開啟的,單獨發他讓他執行。
關閉
@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ControlStorage\DevicePolicies" /v WriteProtect /t reg_dword /d 1
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 delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ControlStorage\DevicePolicies" /v WriteProtect /f
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