打开注册表,在运行框里输入regedit.exe进入注册表编程界面,在进行以下操作
1、首先,关闭USB存储设备的盘符自动分配,打开注册表,找到
HKEY_LOCAL_MACHINE SYSTEM CurrentControlSet Services USBSTOR, 将"Start"的值改为4(禁止自动启动),默认为3是自动分配盘符2、干掉USB存储设备的作用文件∶进入WINDOWS系统目录,找到c:Windowslinf,这里说明一下,USB存储设备的作用文件有两个,分别是usbstor.inf和usbstor.pnf,因为后续可能需要重新打开USB功能,所以不要删除它,建议拷贝到其他位置,当然你要暴力一点,删除它也没关系,但记得做好备份。
我用两条批处理指令实现∶
copy %Windir%usbstor.inf %Windir%infusbstor.inf /y >nul
copy %Windir%usbstor.pnf %Windir%infusbstor.pnf /y >nul
del %Windir%usbstor.pnf /q/f >nul
del %Windir%usbstor.inf /g/f >nul
3、然后,禁止将电脑里的资料拷贝到USB存储设备,意思是把USB存储设备设置只读的,干成残废。
打开注册表∶定位到HKEY_LOCAL_MACHINE SYSTEM CurrentControlSet Control,在其下新建一个名为"StorageDevicePolicies"的项,选中它,在右边的窗格中新建一个名为“WriteProtect”的DWORD值,并将其数值数据设置为1
嘿嘿,有了这一条,你就是能用USB存储设备,也只能单方面读取数据了,也算是半个残废了
到此,基本上第一个过程基本完成,实现的功能包括∶禁止使用USB存储设备,不影响其他 USB外设,就算要用,也把 USB存储设备干成残废(只读)。接下来说第二个部分∶如何开启?(部分用户需要使用 USB存储设备)实际上,逆向操作以上步骤就可以完成开启,但为了表达的更完整一些,我还是把过程写下来1、我到
HKEY_LOCAL_MACHINE SYSTEM CurrentControlSet Services USBSTOR, 将"Start"的值改为 3
2、恢复USB存储设备作用文件,还是4行指令∶
copy %Windir%usbstor.inf %Windir%infusbstor.inf /y >nul
copy %Windir%usbstor.pnf %Windir%infusbstor.pnf /y >nul
del %Windir%usbstor.pnf /q/f >nul
del %Windir%usbstor.inf /g/f >nul
完成后,用户可使用 USB存储设备,但不能往里面写入任何内容!你不信?不信就试试嘛,俗话说的好∶实践出真知!不好意思,扯远了!
这样,关闭也写了,开启也写了,接下来的事情,你知道的。批处理代码,哈哈!
关闭过程∶
@echo off
reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR" /v WriteProtect /t reg_dword /d 1/f
reg add
"HKEY_LOCAL_MACHINESYSTEMCurrentControSetServicesUSBSTOR"
/v Start /t reg dword /d 4/f
copy %Windir%infusbstor.inf %Windir%usbstor.inf /y >nul
copy %Windir%infusbstor.pnf %Windir%usbstor.pnf /y >nul
del %Windir%infusbstor.pnf /g/f >nul
del %Windir%infusbstor.inf /q/f >nul
@echo on
开启过程∶
@echo off reg add
"HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR" /v Start /t reg_dword /d 3/f
copy %Windir%usbstor.inf %Windir%infusbstor.inf /y >nul
copy %Windir%usbstor.pnf %Windir%infusbstor.pnf /y >nul
del %Windir%usbstor.pnf /q/f >nul
del %Windir%usbstor.inf /q/f >nul
@echo on
将以上代码保存为两个BAT文档,然后放进Windowssystem32目录下,比如 DisableUSB.bat 和 EnableUSB.bat
然后直接在运行里面输入指令∶DisableUSB(关闭)EnableUSB(开启)