16
Script to disable nic powersaving
Posted by jbjorkman on March 16, 2010 underDeprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/formatting.php on line 82
VBScript
Option Explicit
Const HKLM = &H80000002
Dim oShell, oReg, oWMI, aryNICs, oNIC, strNICName, strNICId, intPNPCap, intNewPNPCap,strResultSet oShell = WScript.CreateObject("Wscript.Shell")
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set aryNICs = oWMI.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each oNIC in aryNICs
strNICid=Mid(oNIC.Caption,6,4)
strNICName=Mid(oNIC.Caption,12,len(oNIC.Caption)-10)
oReg.GetDWORDValue HKLM, "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & strNICid & "\","PnPCapabilities",intPNPCap
if (intPNPCap and 56)=56 then
strResult=strResult & "Powersaving already disabled for " & strNICName & vbCRLF
else
oReg.SetDWORDValue HKLM, "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & strNICid & "\","PnPCapabilities",(intPNPCap or 56)
oReg.GetDWORDValue HKLM, "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & strNICid & "\","PnPCapabilities",intNewPNPCap
if intNewPNPCap=intPNPCap then
strResult=strResult & "Couldn't change settings for " & strNICName & vbCRLF
else
strResult=strResult & "Disabling Powersave for " & strNICName & "(" & intPNPCap & ">" & intNewPNPCap & ")" & vbCRLF
end if
end if
Next
oShell.popup strResult,10,"Disabe NIC Powersaving",64
Set oReg = Nothing
Set oWMI = Nothing
Add A Comment
You must be logged in to post a comment.