以前写过一个禁用USB存储设备的批处理。链接: http://novell.me/master-diary/2010-01-16/disable-usb-disk.html
很多人问起启用的怎么写?尽管已经有提示,其实就是反着来,原来是去除文件的权限,启用时就是加回权限,另外还有一处注册表设置。
下面给出启用USB存储设备的批处理。网上的很多代码都是缘自我原始的改的,或者去除了版权信息(本来也没什么版权就是了,借用的微软的知识库提供的信息,只不过写成批处理方便执行罢了),或者去掉了无关的cls命令。但有一个“印记”是一直没有去除的。就是我当时取用的是%temp% 这个临时目录,名字也是usb_temp ,这是很多人一直没改的。看来国人也就这点本事,去掉版权信息这一行当做得相当好。
好了不多说了,将以下代码存为.bat 或者.cmd 文件,以管理员身份运行即可。
当时测试环境为Windows XP,其它系统没做测试。
cacls %SystemRoot%\inf\usbstor.inf /e /c /g system:c
cacls %SystemRoot%\inf\usbstor.inf /e /c /g "power users":c
cacls %SystemRoot%\inf\usbstor.inf /e /c /g users:c
cacls %SystemRoot%\inf\usbstor.inf /r "everyone" /e
cacls %SystemRoot%\inf\usbstor.PNF /e /c /g system:c
cacls %SystemRoot%\inf\usbstor.PNF /e /c /g "power users":c
cacls %SystemRoot%\inf\usbstor.PNF /e /c /g users:c
cacls %SystemRoot%\inf\usbstor.PNF /r "everyone" /e
echo Windows Registry Editor Version 5.00>>%temp%\usb_temp.reg
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR]>>%temp%\usb_temp.reg
@echo "Type"=dword:00000001>>%temp%\usb_temp.reg
@echo "Start"=dword:00000003>>%temp%\usb_temp.reg
@echo "ErrorControl"=dword:00000001>>%temp%\usb_temp.reg
@echo "ImagePath"=hex(2):73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,\>>%temp%\usb_temp.reg
@echo 52,00,49,00,56,00,45,00,52,00,53,00,5c,00,55,00,53,00,42,00,53,00,54,00,4f,\>>%temp%\usb_temp.reg
@echo 00,52,00,2e,00,53,00,59,00,53,00,00,00>>%temp%\usb_temp.reg
@echo "DisplayName"="USB Mass Storage Driver">>%temp%\usb_temp.reg
@echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Security]>>%temp%\usb_temp.reg
@echo "Security"=hex:01,00,14,80,90,00,00,00,9c,00,00,00,14,00,00,00,30,00,00,00,02,\>>%temp%\usb_temp.reg
@echo 00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00,\>>%temp%\usb_temp.reg
@echo 00,00,02,00,60,00,04,00,00,00,00,00,14,00,fd,01,02,00,01,01,00,00,00,00,00,\>>%temp%\usb_temp.reg
@echo 05,12,00,00,00,00,00,18,00,ff,01,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,\>>%temp%\usb_temp.reg
@echo 20,02,00,00,00,00,14,00,8d,01,02,00,01,01,00,00,00,00,00,05,0b,00,00,00,00,\>>%temp%\usb_temp.reg
@echo 00,18,00,fd,01,02,00,01,02,00,00,00,00,00,05,20,00,00,00,23,02,00,00,01,01,\>>%temp%\usb_temp.reg
@echo 00,00,00,00,00,05,12,00,00,00,01,01,00,00,00,00,00,05,12,00,00,00>>%temp%\usb_temp.reg
regedit /s %temp%\usb_temp.reg
del %temp%\usb_temp.reg
CopyRight http://novell.me
转载请注明出处!本文地址 http://novell.me/master-diary/2011-04-22/enable-usb-driver.html
(责任编辑:Novell迷)