1、首先关闭USB存储设备盘符的自动分配,打开注册表找到
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR,将"Start"的值改为4(禁止自动启动),默认为3是自动分配盘符
clip_p_w_picpath002
2、干掉USB存储设备的作用文件:进入WINDOWS系统目录,找到X:\Windows\inf,这里说明一下,USB存储设备的作用文件有两个,分别是usbstor.inf和usbstor.pnf,因为后续可能需要重新打开USB功能,所以不要删除它,建议拷贝到其他位置
clip_p_w_picpath004
命令如下:
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
3、然后,禁止将电脑里的资料拷贝到USB存储设备,意思是把USB存储设备设置只读的,干成残废。
打开注册表:定位到HKEY_LOCAL_MACHINE\SYSTEM \CurrentControlSet\Control,在其下新建一个名为“StorageDevicePolicies”的项,选中它,在右边的窗格中新建一个名为“WriteProtect”的DWORD值,并将其数值数据设置为1
clip_p_w_picpath006
以上是实现禁止USB存储设备,但不影响打印机等设备的使用
接下来如何开启?(部分用户需要使用USB存储设备) 实际上,逆向操作以上步骤就可以完成开启
1、找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR,将"Start"的值改为3
2、恢复USB存储设备作用文件,还是4行指令:
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

完成后,用户可使用USB存储设备,但不能往里面写入任何内容!批处理代码,哈哈!
关闭过程:
@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(开启)
over!