查询注册表是否禁用USB
@echo off
set "str=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR"
for /f "tokens=2*" %%a in (‘reg query "%str%" /v Start 2^>nul‘) do set "a=%%b"
if "%a%"=="0x4" ( echo USB已经禁用 >>USB已禁用) else ( echo USB未禁用>>USB未禁用)
禁用USB
@echo off
COPY %WINDIR%\inf\usbstor.inf %WINDIR%\usbstor.inf
COPY %WINDIR%\inf\usbstor.PNF %WINDIR%\usbstor.PNF
DEL %WINDIR%\inf\usbstor.inf
DEL %WINDIR%\inf\usbstor.PNF
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f
echo on
解除禁用
@echo off
COPY %WINDIR%\usbstor.inf %WINDIR%\inf\usbstor.inf
COPY %WINDIR%\usbstor.PNF %WINDIR%\inf\usbstor.PNF
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 3 /f
echo on
时间: 2024-11-07 05:33:28