Windows 7 Power Management: Fixing PC Insomnia

By , May 16, 2010 2:25 am

As I’ve mentioned before, putting workstations into a low power standby mode when not in use is a great way to save money. Unfortunately, standby doesn’t always work like it should. Many sysadmins have struggled with applications, settings, and even system drivers that prevent standby from working reliably, or working at all.

There were many scenarios in past versions of Windows where workstations configured to enter standby after a certain period of idle time would refuse to do so, often without many clues as to why. This behavior is commonly (and cleverly) referred to as PC insomnia. While Windows 7 computers can still suffer from insomnia, the latest Windows OS now includes new tools and settings to troubleshoot and resolve it.  There are a variety of things that may prevent a computer from properly entering standby when idle. Common reasons include hardware driver issues, service issues, and open file shares. Windows XP did not include any tools that could help pinpoint what was keeping the system awake, which often made finding the culprit a guessing game. Thankfully, the command line utility POWERCFG.EXE was updated in Windows 7 to include two new options that assist with tracking down insomnia issues.

If you haven’t already, you should check out my previous article about power management in Windows 7 in order to learn about power profiles and POWERCFG.EXE commands.

POWERCFG -REQUESTS

One way to troubleshoot Windows 7 insomnia issues, is the POWERCFG.EXE -REQUESTS command. This command can be used to display a list of applications and drivers that have made requests to prevent the computer from entering standby.

Example output from the powercfg -requests command

In the example above, there are actually two Windows components that are preventing the system from entering standby. The first issue is that Windows wants to keep this particular computer awake because a remote host is connected to a share on the computer . If this computer was acting as a network file server, that would probably be a good thing. But it’s not, so we either need to prevent the computer from sharing files at all, or allow it to enter standby regardless of whether a remote host is connected to a file share. The other issue is that Windows wants to keep this computer awake because it’s connected to a remote file share. While there are probably cases where this behavior is desired, I want Windows to enter standby regardless of whether or not the computer is connected to a remote network share. Otherwise, most workstations would never enter standby! Both of these issues can normally resolved by changing a few hidden power options, which is covered later in this article.

POWERCFG -ENERGY

In a some cases, it may also be useful run POWERCFG.EXE -ENERGY. This command performs a more thorough investigation  in order find potential power management issues, such as those that may be preventing standby. When POWERCFG -ENERGY is run, it detects common issues by monitoring the system for a period of time and capturing system settings and events that may be preventing Windows power management from working properly. When done, the results are written to a HTML file.

By default, POWERCFG.EXE -ENERGY analyzes the system for 60 seconds. However,  the analysis duration can be be set to a larger period of time to detect more sporadic events that are preventing standby. To perform an analysis for 10 minutes, run POWERCFG -ENERGY -DURATION 600. When finished, the results are written to energy-report.html,  or the filename specified with -OUTPUT <FILENAME>.

An example of the output generated by POWERCFG.EXE -ENERGY

While this report is more thorough that POWERCFG -REQUESTS, it may include items that aren’t necessarily related to issues with standby. For example, the report above shows the error USB Suspend:USB Device not Entering Suspend for several USB devices on this computer. While this may affect the computer’s power efficiency at some level,  it’s not the reason that this computer was entering standby. In this case, the standby was being blocked by the  System Required Request initiated by the driver \FileSystem\srvnet. This is related to the Windows network shares, and indicated to me that that standby was  being blocked because a remote host was trying to connect to a share on the client computer. I wasn’t able to see this when running POWERCFG -REQUESTS alone.

Manually Checking Services

If neither of the tools mentioned above help pinpointthe cause of insomnia, you may want to try manually verifying that Windows Services aren’t preventing standby. This troubleshooting method is simple, but a bit tedious:

  1. First, go to Start > Control Panel > Power Options and configure the current power profile so that the system enters standby after 1 minute.
  2. Go to Start > Control Panel > Administrative Tools > Services. Sort the services by the status column.
  3. One by one, stop services that are running. Each time you stop a service, let the computer idle for at least 2 minutes to see if it enters standby. Continue doing this until the computer enters standby. It’s probably best to begin with non-Windows services.
  4. If/when the computer finally enters standby after you’ve stopped a service, make note of that service. Restart the computer so that all services are running again. Stop that particular service again and wait for the computer to idle into standby.
  5. If the computer idles to standby, you have found the service that is preventing system standby.

What services could be causing insomnia? Some anti-virus applications have been known to prevent the system from entering standby for various reasons. Older or poorly-written services may also be the cause of PC insomnia.

Treating Insomnia

Windows 7 includes several power settings that may be useful for resolving PC insomnia. Interestingly, some of them are hidden and must be enabled in the system registry. Below are some common settings and methods for treating insomnia.

Allow Standby with Remote Opens

By default, Windows 7 will attempt to prevent system standby when connected to a  a remote share or file. Presumably, this is to prevent any ongoing file transfers over the network from failing due to the system unexpectedly entering standby. But there are many cases where the system is connected to a remote share and it is okay to enter standby. Windows 7 includes a setting to allow the computer to enter standby, but it may be missing from the advanced power options dialog box. This .reg file will unhide the “Allow sleep with remote opens” option AND set it to Yes for three default power profiles (Balanced, High Performance, and Power Saver) in Windows 7:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d]
"Attributes"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d\DefaultPowerSchemeValues\381b4222-f694-41f0-9685-ff5bb260df2e]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d\DefaultPowerSchemeValues\8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d\DefaultPowerSchemeValues\a1841308-3541-4fab-bc81-f71556f20b4a]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001

Although the registry entries above will configure the three default power profiles, it won’t apply the settings to custom power profiles. To do that, you’ll need to find the Power Scheme GUID of the power profile you created by using POWERCFG.EXE /LIST and then run these commands:

POWERCFG.EXE /SETACVALUEINDEX <POWER SCHEME GUID> 238c9fa8-0aad-41ed-83f4-97be242c8f20 d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d 1
POWERCFG.EXE /SETDCVALUEINDEX <POWER SCHEME GUID> 238c9fa8-0aad-41ed-83f4-97be242c8f20 d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d 1

Allow Standby when Sharing Media

If the system is configured with file or media sharing enabled, Windows 7 may prevent the system from entering standby while users are connected to files or shares hosted on the system in order to prevent file transfers from being interrupted. Sometimes, media, file, and printer sharing may be enabled on the workstation without the user or the sysadmin knowing it. To make matters worse, there are some network applications installed that tend to scan network shares at regular intervals, which may prevent standby.

This behavior can be disabled by setting  “When sharing media” to “Allow Computer to Sleep” within the advanced settings of a power profile. The setting shouldn’t be hidden by default. To apply this setting to a custom Windows 7 power profile, these commands can be used:

POWERCFG.EXE /SETACVALUEINDEX <POWER SCHEME GUID> 9596fb26-9850-41fd-ac3e-f7c3c00afd4b 03680956-93bc-4294-bba6-4e0f09bb717f 0
POWERCFG.EXE /SETDCVALUEINDEX <POWER SCHEME GUID> 9596fb26-9850-41fd-ac3e-f7c3c00afd4b 03680956-93bc-4294-bba6-4e0f09bb717f 0

Add Power Request Override

While applications can request that Windows to keep the system awake, that doesn’t mean that the OS should always listen. Applications make power requests like this for several reasons. For example, Windows Update may make a request keep to computer awake while updates are being installed or a reboot is pending. It’s actually very easy to implement a power request that blocks standby, which means it could be abused by a service or process that thinks it knows what’s good for it. If the results from POWERCFG -REQUESTS or POWERCONFIG -ENERGY show that a particular service or process is making a lot of unnecessary power requests, there is a way in Windows 7 to ignore those requests. To learn more about overriding a power requests, browse to the “Overriding a Power Request” section of this Microsoft paper.

Don’t Allow System Required Policy

If you’ve tried everything but still can’t get that  insomniac system to enter standby when idle, there is one last setting that you can use in a last ditch attempt.

However,the “Allow System Required Policy” power setting may also cause Windows to ignore valid requests to keep the computer awake. Therefore, this setting should only be used if nothing else works and you’ve tried using a Power Request Override to ignore specific drivers, processes, and services. This registry entry will unhide the setting:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\A4B195F5-8225-47D8-8012-9D41369786E2]
"Attributes"=dword:00000000

To disable power request overrides for a power profile, these commands can be used:

POWERCFG.EXE /SETACVALUEINDEX <POWER SCHEME GUID> 238C9FA8-0AAD-41ED-83F4-97BE242C8F20 A4B195F5-8225-47D8-8012-9D41369786E2 0
POWERCFG.EXE /SETDCVALUEINDEX <POWER SCHEME GUID> 238C9FA8-0AAD-41ED-83F4-97BE242C8F20 A4B195F5-8225-47D8-8012-9D41369786E2 0

What about Narcolepsy?

Another common issue with Windows systems that enter standby is PC Narcolepsy.  PC Narcolepsy refers to a behavior of the Windows Operating System, where a computer that resumes standby from a Wake-on-LAN (WOL) or scheduled wakeup event will enter standby again after 2 minutes unless there is user interaction, such as pressing a key on the mouse or keyboard. In Windows XP, there wasn’t any way to change this behavior. Fortunately, Windows 7 introduces a new power option that can change the amount of time that the computer resumes from standby:  System unattended sleep timeout. However this setting is hidden in the power profile by default. Why is it hidden? I’m not quite sure. Perhaps because it could be confused with the standby timeout setting. It can be unhidden using this reg file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0]
"Attributes"=dword:00000000

Once unhidden, this setting will be visible in the advanced power options dialog. However, most sysadmins need a way to automate the configuration of this setting. Like several of the settings above, this can be done if you know the GUID of the power profile that you want to set this setting on:

POWERCFG.EXE /SETACVALUEINDEX <POWER SCHEME GUID> 238c9fa8-0aad-41ed-83f4-97be242c8f20 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 <DURATION IN SECONDS>
POWERCFG.EXE /SETDCVALUEINDEX <POWER SCHEME GUID> 238c9fa8-0aad-41ed-83f4-97be242c8f20 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 <DURATION IN SECONDS>

22 Responses to “Windows 7 Power Management: Fixing PC Insomnia”

  1. Pat Reynolds says:

    Thanks Boyd for all of this wonderful information. You confirmed what I was looking in to about not being able to go to sleep. One thing though is my computer is set up so only the System account can change the registry values so I used powercfg to make the changes for me. The following command works for the Balanced profile to enable Allow sleep with remote opens: powercfg /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 238c9fa8-0aad-41ed-83f4-97be242c8f20 d4c1d4c8-d5cc-43d3-b83e-fc51215cb04d 1

    • Boyd says:

      Ah yes, some registry keys do have ACLs to do this. I’m glad you found a solution. You could also use psexec.exe, which allows you to run commands under the SYSTEM account. Thanks for the comments!

  2. [...] folks wouldn’t understand what “remote opens” were.     There’s a very helpful blog post here which explains a number of hidden power/sleep settings in gory detail.   Low and behold [...]

  3. Ben says:

    I used powercfg to change “when I close the lid:”
    I see my changes in powercfg -q

    yet from the control panel applet the changes do not reflect what was done with powercfg
    Is this a bug?

    • Boyd says:

      Hey Ben,

      I was able to reproduce the behavior you’re seeing on my Windows 7 workstation. The setting doesn’t appear to change in Windows form that’s linked from “choose what closing the lid does” on the left side of the Power Options control panel. However, the setting is accurately reflected if you go to Change plan settings -> Change advanced power settings -> Power buttons and lid -> Lid closing action.

      After some quick testing, it looks like the settings in that form are actually tied to the “Balanced” power profile for some reason. The GUID for this scheme is “381b4222-f694-41f0-9685-ff5bb260df2e” on my workstation. Therefore, using a command like this one will update that form: powercfg -setacvalueindex “381b4222-f694-41f0-9685-ff5bb260df2e” “4f971e89-eebd-4455-a8de-9e59040e7347″ “5ca83367-6e45-459f-a27b-476b1d01c936″ 1

      I’m not sure if this is a bug, or just a poorly designed form. Interestingly, changing the settings through that form did cause the active power scheme to be changed. You should probably test the behavior of changing the “lid close” setting to confirm that it works.

      Hope that helps,

      Matt

    • Ben says:

      Hi, thanks for replying and testing.
      I also did some of my own and saw that when using the applet to change the “lid” option to “do nothing” – it did it for all the power schemes not just the active one. [via regshot comparison]

      So I created a script to perform the same powercfg setac/setdc to all the power schemes affecting even the balanced power scheme which is the one you discovered as being linked to the applet.

      btw our balanced guids are the same. guess its a universal guid.

      • Boyd says:

        Thanks for the follow-up. You’re right, that applet did apply the “closing lid” setting to all of the power schemes… interesting. I’m glad you figured it out.

  4. GLyons says:

    You refer to “setting is hidden in the power profile by default”. Is there a document that lists all settings including hidden ones. The reason I ask is that I am trying to reproduce a custom plan as the “Power saver” plan but, despite all 32 settings in my custom plan being set identically in the Power saver plan, the behaviour of the latter is different. I suspected that hidden settings differed but you are the only source I’ve found that acknowledges the existence of hidden properties/settings. I’ve checked against powercfg outputs without success [for example, I couldn't even find the "System unattended sleep timeout" in there].

    • Boyd says:

      Unfortunately, I do not know of any documentation that lists all settings including hidden ones… possibly because not all of the settings are supported by all PC hardware. You might be able to look them up yourself in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings. The keys under this key seem to follow this heiarchy:
      Subroup GUID (i.e. Hard Disk)
      -> Power Setting GUID (i.e. Turn off hard disk after…)
      -> -> Possible setting values

      If I remember correctly, any Power Setting GUID that has the value “Attributes” set to 0×00000001 (1) is hidden.

      • GLyons says:

        Thanks. I’ll start hunting down the hidden ones in use in the power scheme I’m trying to manipulate.

  5. GLyons says:

    I discovered some useful things while chasing my Windows 7 power management sleep issues so I thought I’d pass them on.
    1 The command line powercfg -qh will list all power management settings including hidden ones.
    2 These MS documents on TechNet helped me to understand what the settings meant: PMPolicy_Windows.docx, ProcPowerMgmtWin7.docx, AvailabilityRequests.docx, COR-T540_en.pptx, AwayMode.docx

  6. mike says:

    The allow standby with remote opens registry seetings fixed my lack of sleep!.
    Thanks!

  7. Charlie says:

    For Windows 7 standby trouble: driver \FileSystem\srvnet
    running cmd in administrative privilege “powercfg -requestsoverride driver \FileSystem\srvnet system” and reboot system and now my system’s automatic standby is working again! Nice!!!

  8. [...] I'm guessing the base issue is similar. I found my solution, by following the instructions found at Windows 7 Power Management: Fixing PC Insomnia The specific information that helped me, is the section under 'Allow Standby with Remote Opens' [...]

  9. John Benton says:

    I am working on a project for energy savings. Unfortunately, I have the following problems. First, the OS that I am dealing with is WEPOS v1.1, which is effectively Windows XP. Secondly, I have a critical business application that appears to be preventing the computer to simply go into Standby mode after some period of time.

    Any ideas on what can be done on the Windows XP box using powercfg.exe to try and prevent the business application from blocking the Standby setting?

    Thanks!

    John B

  10. Terry Y. says:

    I was at the point of throwing this machine out (because it won’t sleep, when I found this great article. It has shown me that I have a “remote share” problem.

    However, I am not a “regedit” person. Could someone guide me through how to get the above “Allow Standby with Remote Opens” registry changes into my computer?

  11. Terry Y. says:

    Regarding my help request above.

    I figured it out; simply follow the path and make the changes. Duh!

    Thanks anyway guy’s, you made my day!

  12. James C. says:

    Thanks for the guide!
    Tried the above with remote ports, every service stopped etc. but still couldn’t get computer to sleep on it’s own.
    Only thing that worked was the last ditch system required policy, which is a pain because the PC now turns off when I’m watching a movie.

    Thanks anyway!

  13. Bob Hirons says:

    Hi Boyd
    Thanks for the above information, it has given me a route to fix my Win8 sleep problems.
    The only problem I have is when I look at the advance power settings menu the ‘Multimedia’ setting is hidden.
    Do you have a .reg fix to un-hide the setting please?
    Many thanks
    Bob

  14. Luke H says:

    Guys — for anyone who may want to try a fix I came up with for this, head over to the TechNet forums and see the link below

    http://social.technet.microsoft.com/Forums/en-US/w8itprogeneral/thread/a4a7cc99-a49a-42a8-b2af-aff748623c34/#515aa336-1a20-4b4e-ba23-e75cd16fc2a3

  15. [...] diagnostic tools windows provides and browsing obscure Technet threads. In the end, none of the common solutions worked for me. I had media sharing disabled, fsmgmt.msc showed no active sessions, and my drivers [...]

Leave a Reply

Panorama Theme by Themocracy