So in this post we will talk a bit about power management and settings for your devices you connect inside or outside your computer, this could be network adapters, display adapters, smart card readers, audio devices etc..

It could be either these Power Management options or Device specific settings below

image

image

Your property page may look completely different, but I try to use this example and provide a step by step guide how to change the settings.

Wonder why these property pages are different? Simply because vendors use different technology in their devices and technology revolve and get better and better and more power efficient, if you have an old device chances are high you don’t get any vendor specific power management at all.

Lets look at the Power Management page again

image

Lets start with the second option ”Allow this device to wake the computer”. What does this option actually mean? If you have a mouse or keyboard with this option you can simply tap or move it to wake up the computer.

Note! Everything in this post is tested on Windows 8, so may require some tweaking for Windows 7/Vista

So it is time for some scripting, and the command used today is powercfg.exe. Open a elevated command prompt and hit powercfg /? and this will show

image

first let us check what devices that can actually wake up the system by typing powercfg /devicequery wake_programmable

image

In this list I can see my Intel 82579LM network adapter so I should be fine by setting this option. So to enable this setting simply use the command deviceenablewake followed by your device name, showed by the command line above. My example looks like this

powercfg /deviceenablewake “Intel(R) 82579LM Gigabit Network Connection”

Ok, done! But now what about the first and third option that appears?

image

Powercfg will not help us here, so I went to search thru MSDN and the WMI repository and found nothing interesting. I have to make a note for the WMI Class MSPower_DeviceWakeEnable, this one is not documented equals not supported, but it could work but I have seen users getting error message 0X80041010 when trying to use this, and that means Class not found.

So I will try to found a more reliable way to set these settings. So what I do – Simply record when I do the change with procmon.exe

Make sure to record as short period as possible and use the filter to exclude things you don’t want to see and then use the Tools > Registry Summary to find a place where it have been doing a small amount of writes, yes there it is – take a look

image

Double click this row and that will filter only the interesting part and right click and jump to.. and that will take you directly to the registry key.

image

So monitor this key, until you get your settings right, for me a HEX value of 0 did the trick. Restart your computer and see if you changes are applied.

Ok so the next time, do I really need to open Procmon? No, just keep in mind the registry base, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\, open the Details pane of the device you want to edit and browse to Driver Key, there it is, the GUID and Device ID.

image

So what about making a PowerShell script that change this? Just to give a first hint what this could look like, without error handling etc

$registryBase = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}"

# the name OR index of the device
$DeviceID = 10
$DeviceName = $null

# Registry name and value to be edited
$regName = "PnPCapabilities"
$regValue = 0 # To write HEX value use 0x example 0x110

if ($DeviceID -ne $null) 
{
    $adapter = Get-WmiObject -Class Win32_NetworkAdapter -Namespace "root\cimv2" -Filter "deviceId='$DeviceID'"
}
elseif ($DeviceName -ne $null)
{
    $adapter = Get-WmiObject -Class Win32_NetworkAdapter -Namespace "root\cimv2" -Filter "name='$DeviceName'"
}
else
{
    Write-Host "You must supply the script with either Device ID or Device Name" -ForegroundColor Red
    break;
}

if ([String]$adapter.DeviceID.Length -eq 1)
{    $registryBase = $registryBase + "00"+[string]($adapter.DeviceID) }
if ([String]$adapter.DeviceID.Length -eq 2)
{    $registryBase = $registryBase + "0"+[string]($adapter.DeviceID) }
if ([String]$adapter.DeviceID.Length -eq 3)
{    $registryBase = $registryBase + "0"+[string]($adapter.DeviceID) }
if ([String]$adapter.DeviceID.Length -eq 4)
{    $registryBase = $registryBase + "\"+[string]($adapter.DeviceID) }

Write-Host "Writing $regName and $regvalue in $registryBase"
New-ItemProperty -LiteralPath $registryBase –Name $regName –Value $regValue -Type DWORD -Force

I think this is rather strange forward, just make sure to edit the script with your device id or device name and registry name and value and you are good to go.

Regarding the other settings:

image

These settings are most probably located in the same place in registry, so just find the correct registry name and edit with your value in the script and you should be good to go.

Before I stop I want to highlight two old KB articles that could help you as well

http://support.microsoft.com/kb/257277

http://support.microsoft.com/kb/837058

and one URL for power management for Network devices in Windows 7.

http://technet.microsoft.com/en-us/library/ee617165(WS.10).aspx

Advertisements