bat生成vbs經過註冊表禁用或啓用USB端口

在網上找到的資料,通過本身簡單的修改調整,經過bat生成vbs文件,由vbs文件操做註冊表的鍵值,達到啓用和禁用USB端口的目的。spa

固然,你也能夠徹底使用BAT操做註冊表來完成修改註冊表的鍵值的目的,具體方式留之後完善,若是你有好的想法,記得告訴我哦!code

USB_Disable.bat文件代碼:blog

@echo off
echo On Error Resume next>USB_Disable.vbs
echo Dim WshShell>>USB_Disable.vbs
echo Set WshShell = WScript.CreateObject("WScript.Shell")>>USB_Disable.vbs
echo wshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\start", 4, "REG_DWORD">>USB_Disable.vbs

cSCript USB_Disable.vbs
del USB_Disable.vbs
pause

USB_Enable.bat文件代碼:ip

@echo off
echo On Error Resume next>USB_Enable.vbs
echo Dim WshShell>>USB_Enable.vbs
echo Set WshShell = WScript.CreateObject("WScript.Shell")>>USB_Enable.vbs
echo wshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\start", 3, "REG_DWORD">>USB_Enable.vbs

cSCript USB_Enable.vbs
del USB_Enable.vbs
pause

把以上兩段代碼保存爲bat文件,能夠雙擊運行。it

相關文章
相關標籤/搜索