关闭和开启USB功能网络
一,开启USB功能。
ide
::USB-Enable @echo off :step1 if exist C:\Windows\INF\usbstor.inf (cls&goto :step2) else (cls&goto :step3) :step2 if exist C:\Windows\INF\usbstor.inf.bak (cls&goto :exit) else (cls&goto :copy2) :step3 if exist C:\Windows\INF\usbstor.inf.bak (cls&goto :copy1) else (cls&goto :exit) exit :copy1 copy C:\Windows\INF\usbstor.inf.bak C:\Windows\INF\usbstor.inf reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 3 /f :copy2 copy C:\Windows\INF\usbstor.inf C:\Windows\INF\usbstor.inf.bak :exit exit
2、关闭USB功能。
测试
::USB-Disable @echo off :step1 if exist C:\Windows\INF\usbstor.inf.bak (cls&goto :step2) else (cls&goto :step3) :step2 if exist C:\Windows\INF\usbstor.inf (cls&goto :del) else (cls&goto :reg) :step3 if exist C:\Windows\INF\usbstor.inf (cls&goto :copy) else (cls&goto :exit) exit :reg reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f :copy copy C:\Windows\INF\usbstor.inf C:\Windows\INF\usbstor.inf.bak del /s C:\Windows\INF\usbstor.inf reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f :del del /s C:\Windows\INF\usbstor.inf reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 4 /f :exit Exit
三,总结一下spa
1,脚本在window xp 7和win10上都有测试执行成功,若是须要readonly须要将注册表值改成1,有兴趣的能够测试一下。
it
2,脚本在GPO下发后生效能成功执行,有个别问题网络异常执行不成功。class