NOTE: This will not appear to take affect via the GUI (Computer management console) until after you reboot the machine. The changes are made, however, immediately to the registry.
' AUTHOR: Will Steele
' CREATED: 1/22/2009
' PURPOSE: The script turns off power management for USB Root Hubs.
' NOTE: Change (line 8) HcDisableSelectiveSuspend to &H00000000 to enable power management for all USB Root Hubs.
' Change (line 8) HcDisableSelectiveSuspend to &H00000001 to disable power management for all USB Root Hubs.
Const HKEY_LOCAL_MACHINE = &H80000002
Const HcDisableSelectiveSuspend = &H00000001
strValueName = "HcDisableSelectiveSuspend"
strComputer = "."
DriverDesc = "DriverDesc"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{36FC9E60-C465-11CF-8056-444553540000}"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
set re = new regexp
re.pattern = "Host Controller"
pathCount = 0
For pathCount = 0 To UBound(arrSubKeys)
If pathCount < 10 Then
strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{36FC9E60-C465-11CF-8056-444553540000}\000" & pathCount
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,DriverDesc,strValue
set test = re.Execute(strValue)
If test.Count Then
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath,DriverDesc,strValueName
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,HcDisableSelectiveSuspend
'WScript.Echo (CStr(strKeyPath & "\" & CStr(strValueName) & " set to - " & CInt(HcDisableSelectiveSuspend)))
End If
Else
strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{36FC9E60-C465-11CF-8056-444553540000}\00" & pathCount
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,DriverDesc,strValue
set test = re.Execute(strValue)
If test.Count Then
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath,DriverDesc,strValueName
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,HcDisableSelectiveSuspend
'WScript.Echo (CStr(strKeyPath & "\" & CStr(strValueName) & " set to - " & CInt(HcDisableSelectiveSuspend)))
End If
End If
Next
If CStr(HcDisableSelectiveSuspend) = 0 Then
WScript.Echo ("All USB Root Hubs have been configured to have power management enabled.")
Else
WScript.Echo ("All USB Root Hubs have been configured to have power management disabled.")
End If
Update
I found almost the same exact script elsewhere after the fact: http://www.hugsforhackers.org/scripting/disable_power_management.html. Wish I had known about that guy 8 months ago.
Thanks Will for this great script! We have some issues with a USB smart card reader and we are barking up the power-save tree too. I was hoping to find a script to disable this and voila! Here it is!
ReplyDeleteWow! Great script! Thank you!
ReplyDeleteQuick question: I'm not super savvy on these type scripts - is this specific to any version of Windows? Eg. will it work on XP and Vista?
Thanks again!
This works specifically on 2000 and XP. It can be used on Vista, but, I have had to call the .vbs file from a .bat file. I'm sure with a little reworking it could be Vista compatable.
ReplyDeleteGlad I could help. Out of frustration with manually doing the task I knew there had to be a better way.
Or you can simply add one key to disable all USB power management. ;)
ReplyDeletehttp://support.microsoft.com/kb/895962
Basically:
Create Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USB
Create Value: REG_DWORD: DisableSelectiveSuspend = 1
No more power management on any USB and no more tab for it either.
Good point. We need to leave out client machines with the ability to manually override out setting. This is a good alternative for folks who just want to do away with it altogether.
ReplyDelete