Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help - Edit registry value to set NIC power managent

Status
Not open for further replies.

sktala

MIS
Jan 2, 2007
12
US
Hi everyone,

I need to configure the power management on the NIC. I need to disable "Allow the computer to turn off this device to save power"

I have this script, but when I run i get "Broadcom NetXtreme 57xx Gigabit Controller
Device Number is: 0001
D:\Script\Sample Scripts\Change NIC PM.vbs(21, 2) SWbemObjectEx: Type mismatch

I'm desperately need help to get going with this. Could you help me figure out what's wrong? Thank you so much.


Const HKEY_LOCAL_MACHINE = &H80000002
' On Error Resume Next
strComputer = "."
strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"
strValueName = "PnPCapabilities"
dwValue = "294"

Set StdOut = WScript.StdOut
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set arrayNetCards = GetObject("WinMgmts:{impersonationLevel=impersonate}//./root/Cimv2")_
.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeId=0")
For Each objNetCard In arrayNetCards
WScript.Echo objNetCard.name
' strDeviceID = UCase(objNetCard.PNPDeviceID)
strDeviceID = Mid(objNetCard.Caption,6,4) 'Get the DeviceID of the NIC
WScript.Echo "Device Number is: " & strDeviceID
'Change the Power Management Values
objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strDeviceID,strValueName,dwValue
wscript.echo "HKEY_LOCAL_MACHINE\" & strkeyPath & vbNewLine & "Contains: " & dwValue
Next

Set objReg = Nothing
Set objWMIService = Nothing
 
> objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strDeviceID,strValueName,dwValue
> wscript.echo "HKEY_LOCAL_MACHINE\" & strkeyPath & vbNewLine & "Contains: " & dwValue

I think you mean this.

[tt] objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath[highlight] & [/highlight]strDeviceID,strValueName,dwValue
wscript.echo "HKEY_LOCAL_MACHINE\" & strkeyPath [red]& strDeviceID[/red] & vbNewLine & "Contains: " & dwValue
[/tt]
You can assign dwValue=294 as number rather than a string "294", even though the conversion is automatic.
 
I was just looking at this on a Vista machine and it does not work. ONe thing I noticed is that you report a rwg key contains a value of 294, but you do not read the registry key to verify that.

[red]Sent while vactioning in lovely Cancun Mexico, please excuse any incomplete thoughts or spelling errors which may or may not be the result of too many strawberry daqueries.[/red]

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top