@echo off
:禁用USB接口
reg add "HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 3 /f
reg add "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]" /v WriteProtect /t reg_dword /d 1 /f
attrib -r %Windir%\inf\Usbstor.inf
attrib -r %Windir%\inf\Usbstor.PNF
echo y|cacls %Systemroot%\Inf\Usbstor.pnf /g everyone:f
echo y|cacls %Systemroot%\Inf\Usbstor.inf /g everyone:f
pause
:启用USB接口
@echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ControlStorageDevicePolicies" /v WriteProtect /t reg_dword /d 1 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t reg_dword /d 3 /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
在图形界面设置禁止电脑文件复制到U盘:
同时按住【win+R】组合键,打开运行窗口。
在运行窗口中输入【gpedit.msc】,点击【确定】打开本地组策略编辑器。
依次打开【计算机配置/管理模板/系统/可移动存储访问】,双击打开【可移动磁盘:拒绝写入权限】。
随后,弹出权限设置页面,选择【已启用】,再点击【确定】即可。
最后,还需要刷新组策略:同时按住【win+R】打开运行窗口,输入【cmd】并点击【确定】。
打开命令页面后,输入【gpupdate /force】并回车执行,刷新完毕即可