Purpose & Scope
The most annoying issue I've had since upgrading from Windows 7 to Windows 10 in the summer 2015 has been the inability of that system to remain asleep. Out-of-the-box my brand new desktop Windows installation has the bad habit to keep waking up from sleep or hibernate for no obvious reason. Most annoyingly it tends to happen in the middle of the night so that if someone is sleeping next to the computer it will no doubt wake her up too. Yes, sleeping next to your computer is a valid use case. Not everybody can afford 6 bedrooms mansions, dear Microsoft executives.Until recently I was not able to investigate that problem thoroughly, this is about to change.
Rant
First of all I believe such an issue deserves a good rant.Why on earth would Microsoft ship its flagship product with such blatant problems is beyond me.
Moreover Microsoft inability to tackle those issues over 2 years following the initial release is plain disrespect for their customers and users.
It's not like they don't know about it's been reported soon after release on August the 10th 2015. At time of writing the last post on that massive thread was from just three days ago, that is the 15th of November 2017.
Microsoft Windows team is really showing negligence and incompetence there.
I'm done ranting.
Symptoms
In the more than two years using Windows 10 I've had various manifestation of that problem.Windows would wake up after anything from a few minutes to a few hours of sleep.
I was once in a situation where it would wake up instantly after going into hibernate. While most frustrating it did provide me the opportunity to identify the problem since I could easily reproduce it.
Sometimes Windows just does not go to sleep after the specified period of inactivity. That's often caused by power requests issued by drivers such as a Sound Blaster card doing Dolby Digital Live or a faulty web browser thinking it's downloading something when it isn't anymore, Vivaldi I'm looking at you.
Investigation
When it comes to power management Windows has a useful command line tools named powercfg which can be used to diagnose and fix issues.However with that particular problem powercfg -lastwake often comes up empty after a wake thus providing no insight on what caused it.
I recently realised that if you execute powercfg -requests shortly after your PC wakes up you will get this kind of output:
DISPLAY:
None.
SYSTEM:
None
AWAYMODE:
None.
EXECUTION:
None.
PERFBOOST:
[DRIVER] Legacy Kernel Caller
Power Manager
ACTIVELOCKSCREEN:
None.
None.
SYSTEM:
None
AWAYMODE:
None.
EXECUTION:
None.
PERFBOOST:
[DRIVER] Legacy Kernel Caller
Power Manager
ACTIVELOCKSCREEN:
None.
That's when I thought those Legacy Kernel Caller and Power Manager are possibly causing some of those wakes.
Solutions
Typically their are three reasons for your computer sleep issues:- A driver or software is causing it through those requests.
- A device is causing it, typically mouse or keyboard but not only. It could be your mouse is too sensitive and sometimes wakes your PC when not intended.
- Wake timers
Requests override
After identifying the requests for your impromptu wakes you can disable them using powercfg -requestoverride commands such as:powercfg -requestsoverride Driver "Legacy Kernel Caller" System
Here is the requests override I've set on my machine:
[SERVICE]
[PROCESS]
[DRIVER]
Sound Blaster Z SYSTEM
USB Audio Device SYSTEM
Legacy Kernel Caller SYSTEM
Power Manager SYSTEM
[PROCESS]
[DRIVER]
Sound Blaster Z SYSTEM
USB Audio Device SYSTEM
Legacy Kernel Caller SYSTEM
Power Manager SYSTEM
Devices
Devices such as keyboard, mouse or other USB interface can also cause unwanted wake. See powercfg -devicequery to get a list of the devices on your PC.powercfg -devicequery wake_armed will notably list devices capable of waking up your PC. To disarm devices you'll have to use the powercfg -devicedisablewake command. Not all devices are of interest to us. You probably want to restrict your investigation to the ones which are wake programmable, see the documentation linked above for more information.
However powercfg -lastwake command results are not always accurate. For instance mine would report "Renesas USB 3.0 eXtensible Host Controller - 0.96 (Microsoft)" when either of my keyboard and mouse were waking up the PC. That's rather confusing since that Renesas device is not even wake programmable and can therefore not be disabled. Executing powercfg /devicedisablewake "Renesas USB 3.0 eXtensible Host Controller - 0.96 (Microsoft)" would result in the following error message: You do not have permission to enable or disable device wake.
I needed to guess and disable the actual devices causing the wake from the list of programmable devices. Thankfully that's often pretty obvious and easy to test. Also the list of wake programmable devices on your PC is probably not that long.
Wake timers
Once you have taken care of Requests and Devices you will need to watch out for wake timers.I'm still trying to figure out exactly how to best do that. It seems a lot of the Windows 10 issues are caused by wake timers being abused by the system itself.
For now I just disabled wake timers altogether as seen in the screenshot below but that might not be a good enough solution if some of those timers are important to you. For instance when using your PC to record TV shows at specific times.
When waking up from a wake timer the last wake output looks like that:
Wake History Count - 1
Wake History [0]
Wake Source Count - 1
Wake Source [0]
Type: Wake Timer
Owner: [SERVICE] \Device\HarddiskVolume3\Windows\System32\svchost.exe (SystemEventsBroker)
Owner Supplied Reason: Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Reboot' scheduled task that requested waking the computer.
Wake History [0]
Wake Source Count - 1
Wake Source [0]
Type: Wake Timer
Owner: [SERVICE] \Device\HarddiskVolume3\Windows\System32\svchost.exe (SystemEventsBroker)
Owner Supplied Reason: Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Reboot' scheduled task that requested waking the computer.
In that example you can see the infamous Update Orchestrator being responsible. I wonder if there might be a way to disable wakes from Update Orchestrator without have to go through the Task Scheduler as explained there as this seems to not work reliably. Maybe using a request override for the service specified above.
Check your LAN connections
Hibernation had been working fine for a couple of weeks until for some reason it would systematically wake up instantly after hibernating. I tracked down the problem to my LAN connection. All I did was unplug my network cable and I could hibernate again. To solve that issue I had to disable Wake-on-LAN (WOL) for that network adaptor using the device manager.Prevent wakes from networks adapter
Runningpowercfg /lastwake
as administrator shows a network adapter woke up my PC:To prevent that network adapter to wake up my PC I could just execute the following command:
powercfg /devicedisablewake "Intel(R) I210 Gigabit Network Connection"
Offenders
Here we are listing some suspects possibly responsible to wake your computer for no good reason.Logitech G HUB
Runpowercfg -requestsoverride
to get the exact name of the LGHUB process on your machine.Then run the following command to disable its ability to wake your computer:
powercfg -requestsoverride Process "\Device\HarddiskVolume9\Program Files\LGHUB\lghub_agent.exe" Execution Awaymode
Use a bigger hammer
If albeit all your efforts Windows won't stay asleep there is still something you can do to force it to, at least for desktops. Instead of using Sleep you'll need to activate and use Hibernate. It's essentially much the same as Sleep but using your hard drive to persist the state of your machine rather than the RAM. It means that a system in hibernation does not need any power. As a result once in hibernation you can unplug your PC from the wall, or just use a good old power switch. Once the power is cut your PC will obviously not wake up, no matter what, until you put back the power and wake it up yourself.Hibernate file size
After sorting out requests, devices and timers, Hibernate worked for a few weeks until it broke again for some reason.The system would take a long while to shutdown after triggering the hibernation. For a minute or so the HDD led would flash until the system eventually shutdown.
When turning it back it would perform a cold start rather than resuming from hibernation so you would loose all your work.
For a while there I got desperate and tried many combinations of BIOS settings and power plan settings, disabling and re-enabling hibernation, with or without hybrid sleep or fast start-up, all sorts of things really. I even blamed my motherboard manufacturer for it. However none of that did make much sense to me since I had seen Hibernate working just fine a few days earlier.
Then I had a light-bulb moment. Hibernate is basically dumping your RAM unto your system drive, typically an SSD. When Hibernate is enabled Windows creates at the root of your system drive a hidden file called hiberfil.sys used for the purpose of dumping your RAM. I had noticed the size of that file was suspicious, in fact it was only 6GB when my system has 16GB of RAM. Sadly it took me a couple of days to decide to take a closer look at that. It turns out that was my issue. You can run the following command from an administrative command prompt to make sure your hibernation file is large enough to fit all the content of your RAM:
powercfg -h -size 100
I'm guessing Windows is capable of compressing your RAM before it dumps it. Thus the ability to reduce the size of your hibernation dump file. That is probably a nice space saving feature on systems with limited room on system drive. In my case however the size of it was much too small compared to my actual RAM capacity and the system was most certainly failing to compress it to those extremes. Moreover setting your hibernation file size to the exact size of your RAM not only makes sure hibernation won't ever fail, it also speeds up the hibernation process as no compression is required. I have no idea why my hibernation file size was set so low in the first place.
Maximum size hibernation file worked for a while until Windows was again failing to hibernate as described above. Changing the hibernation file size to 40% and then back 100% fixed it again.
Conclusions
We went through the three main reason causing your PC to wake up: requests, devices and timers. We've shared ways to fix each of those in the hope that it will help you sleep at night.We also mentioned a couple of other issues we had on our system regarding Network Adaptors and Hibernate file size.
References
- Microsoft Answer thread - since that website is rather useless I guess you won't find anything useful unless you spend three days reading each posts I guess.
- How to prevent Windows 10 waking from sleep when traveling in bag?
- Windows 10 waking from sleep for unknown reason
- Windows 10 keeps waking from sleep
- Legacy Kernel Caller preventing sleep mode
Last edited: