PDA

View Full Version : Disable USB remotely (W2K)



jpc
10-16-2002, 09:43 AM
Hi!
I've noticed that there isn't an apparent way to disable remotly USB devices. I've spent several days working on one (to avoid getting of my but and do it manually...) and the result is the following:
'_________________________________________

'All the following lines must be separated by a space
'unless they start with a " ' ".
'Freeware made in Portugal by Joćo Pedro Carvalho
'Enjoy...

Option Explicit

Dim WSHShell, RegKey, USBName1, USBName2, USB1, USB2

Set WSHShell = CreateObject("WScript.Shell")

RegKey = "HKLM\SYSTEM\CurrentControlSet\Services\usbhub\Enum \"

'The following 2 lines set variables to read the name of the USB
'device, since these names change from system to system.

USBName1 = WSHShell.RegRead(RegKey & "0")

USBName2 = WSHShell.RegRead(RegKey & "1")

'The following 2 lines define a variable for the path were the
'flags we're going to change lay.

USB1 = "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Enum\" & USBName1 & "\" & "CSConfigFlags"

USB2 = "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Enum\" & USBName2 & "\" & "CSConfigFlags"

'These next lines actualy change the flags of the ROOT_USB to
'disable (1) or enable (0) them.

WSHShell.regwrite USB1, 1, "REG_DWORD"

WSHShell.regwrite USB2, 1, "REG_DWORD"

Set WshShell = Nothing

'2002/10/15 Joćo Pedro Carvalho
'_________________________________________

Note: this script has been tested on windows 2000 (any version) and works. I do not consider my self responsable for any damage on other operating system's registry.