我現(xiàn)在的網(wǎng)絡(luò)環(huán)境中是用腳本做的,只對USB存儲設(shè)備,如U盤、移動硬盤、USB光驅(qū)等,對USB的鍵盤、鼠標(biāo)等無影響!原理就是對USB存儲設(shè)備所需要的驅(qū)動文件進行刪除或恢復(fù),是參考Microsoft KB:823732 而來的!
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;823732如下:在GPO中按不同的要求分調(diào)用下面兩腳本,說明如下:
比如說默認情況下,所有電腦都是在Computer OU下面,為了禁用或開啟的需要,我另建兩個OU: Disable USB/Enable USB,
1、禁止使用(將下面的代碼copy到記事本,然后另存為.vbs),將需要禁止的電腦,移到禁用USB的Disable USB OU中,然后在此OU中的GPO調(diào)用下面的腳本
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\windows\inf\usbstor.pnf") Then
objFSO.DeleteFile("C:\windows\inf\usbstor.pnf")
End If
If objFSO.FileExists("C:\windows\inf\usbstor.inf") Then
objFSO.DeleteFile("C:\windows\inf\usbstor.inf")
End If
If objFSO.FileExists("C:\windows\system32\drivers\usbstor.sys") Then
objFSO.DeleteFile("C:\windows\system32\drivers\usbstor.sys")
End If
If objFSO.FileExists("C:\winnt\inf\usbstor.pnf") Then
objFSO.DeleteFile("C:\winnt\inf\usbstor.pnf")
End If
If objFSO.FileExists("C:\winnt\inf\usbstor.inf") Then
objFSO.DeleteFile("C:\winnt\inf\usbstor.inf")
End If
If objFSO.FileExists("C:\winnt\system32\drivers\usbstor.sys") Then
objFSO.DeleteFile("C:\winnt\system32\drivers\usbstor.sys")
End If
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services\UsbStor"
strValueName = "Start"
dwValue = 4
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
2、解除禁止(將下面的代碼copy到記事本,然后另存為.vbs),對于已禁用的電腦,需要解除的,將需要解除的電腦移到:Enable USB的OU中,然后在OU中的GPO調(diào)用,待可以用后,再移到正常使用的OU中(Computer),紅色部分是具體文件及路徑,需要依你實際情況而定,可以預(yù)先將幾個文件COPY在某個隱藏的共享目錄下!
Set objFSO = CreateObject("Scripting.FileSystemObject")
IF objFSO.FolderExists("C:\windows") Then
If objFSO.FileExists("C:\windows\inf\usbstor.pnf") Then
Else
objFSO.CopyFile "
Usbstor.pnf" , "C:\windows\inf\usbstor.pnf"
End If
If objFSO.FileExists("C:\windows\inf\usbstor.Inf") Then
Else
objFSO.CopyFile
"Usbstor.Inf" , "C:\windows\inf\usbstor.Inf"
End If
If objFSO.FileExists("C:\windows\system32\drivers\usbstor.sys") Then
Else
objFSO.CopyFile "
Usbstor.sys" , "C:\windows\system32\drivers\usbstor.sys"
End If
End If
IF objFSO.FolderExists("C:\winnt") Then
If objFSO.FileExists("C:\winnt\inf\usbstor.pnf") Then
Else
objFSO.CopyFile "
Usbstor.pnf" , "C:\winnt\inf\usbstor.pnf"
End If
If objFSO.FileExists("C:\winnt\inf\usbstor.inf") Then
Else
objFSO.CopyFile "
Usbstor.Inf" , "C:\winnt\inf\usbstor.Inf"
End If
If objFSO.FileExists("C:\winnt\inf\usbstor.sys") Then
Else
objFSO.CopyFile "
Usbstor.sys" , "C:\winnt\system32\drivers\usbstor.sys"
End If
End If
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services\UsbStor"
strValueName = "Start"
dwValue = 3
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
說明:以上在Windows 2000/XP/Vista/Win7 32位的環(huán)境中都能正常,解除禁用的部分,因XP 64/Vista 64/Win7 64的驅(qū)動不一樣,所以不保證能正常運行!