2020-02-17

Windows 11 wakes from Sleep unexpectedly - Solution

How To: Windows 10/11 wakes from sleep unexpectedly in the middle of the night.  Windows 11 / 10 wakes unexpectedly from Sleep.  At the end of this article are steps for "PC does not wake from sleep" -- the opposite problem.

This article was originally written for Windows 10.  Windows 11 is better behaved but still benefited from these steps.   

Follow these steps for stopping a computer from waking from Sleep or if the computer fails to go to sleep as expected.  These steps will stop many, but not all WAKE events.  This is a work-in-progress.

With the advanced steps, below, use with some caution and reservations, as noted. 

Requires local Administrative rights to the workstation.  Steps here include manual override, assuming you are using a non-adminstrative account.  Use these login steps, regardless.  See this keyliner article on why you should always run your computer with non-administrative rights: 
Link: https://keyliner.blogspot.com/2020/02/windows-10-administrative-accounts.html


[2024.10]  After recent BIOS and Microsoft updates, the PC occasionally does not wake from sleep.  Solutions at the end of this article.

[2020.06] Update:  Steps 1 - 8 have worked well with my PC.  No further research needed.  I still do not recommend step 9]


Make all of these changes to fix Sleep problems:

1.  Launch Windows Device Manager as Administrator:
"Administrative rights" also known as "Elevated privileges", or "Elevated rights"
 
Non-administrative users: Do not launch Device Manager through Control Panel.
(The Windows Control Panel is nothing more than a menu; running it with Administrative rights offers no benefit.)

a.  From the Start Menu Search box, type

"C:\Windows\System32\Devmgmt.msc".

b.  From the search results, single-click.  Select "Run as administrator" (or right-mouse-click the found program and select "run as administrator.")

If prompted, type your administrative credentials to login. 
If not prompted, your account already has admin rights.  Consider reviewing this article.)

Click for larger view


2.  Locate and expand "Network Adapters"

Click for larger view

a.  Click each found adapter.  If it has a "[Power Management]" tab,
Most (WAN and PNP) adapters will not have this setting

     uncheck [ ] Allow this device to wake the computer.

b.  If the machine has both a wired and wireless adapter (many desktops and laptops do), make this change for each adapter.

Disadvantage: On some corporate networks, this stops the network administrator from powering-up the machine for maintenance.

If the message:  "You are logged on as a standard user.  You can view device settings in Device Manager, but you must be logged on as an administrator to make changes."  See Step 1.


3.  In Device Manager, locate "Mice and other pointing devices."

Click for larger view
Examine each device, especially the mouse. 
If there is a [Power Management] tab, consider unchecking "[ ] Allow this device to wake the computer"  -- however, I would leave the keyboard with this activity (vs the power button).

Benefit:  A bumped desk will not wake the computer when the mouse jiggles.
Minor drawback:  Only the keyboard can wake the computer.


4.  In Task Scheduler, change how updates happen.

Windows 10 only.
Using steps similar to step 1, Start, search "Task Scheduler"
Open Task Scheduler with administrative rights

a.  On the tree side, expand "Task Scheduler Library"
b.  Expand "Microsoft", then "Windows"

c.  Still in the tree-side, in the long list, locate "UpdateOrchestrator"
     In the center detail list, Locate "Reboot"
     In the [Conditions] tab, uncheck "[ ] Wake the computer to run this task"



Minor Drawback:  Some updates may be delayed.  This is not an issue.  You will be prompted if a reboot is needed and a convenient time can be picked.

Other issue:  Other scheduled tasks in this same general area, discoverable in Step 6, are not editable, even though they run from within Task Scheduler and even though changes are made with administrative rights.  See below for Advanced Disable Steps.

Review and snoop-around other Microsoft Tasks, such as Office updates.
Note several of mine were set to trigger daily at 2:10 AM;  Consider Edit/change these schedules to a different time -- but more importantly, in the [Conditions] tab, confirm the [  ] Wake the computer to run this task.

Within the task, you may find multiple instances:

Again, you don't have to change every one of these, but do snoop around and see if any have the [x] Wake switch checked.


5.  If McAfee Virus Scanner is installed... Uninstall

This reportedly wakes the PC often.

No specific steps listed here, but in general, use the Control Panel's "Programs and Features" to uninstall the program.  Uninstall for this, and other reasons.  Be aware McAfee's uninstall does a poor job uninstalling.   See their website for a more robust un-install tool, which does a better job, but it still does it badly. 

I am similarly suspicious of Symantec, and Avast virus scanners for the same reasons.

I recommend using Microsoft's built-in scanner ("Defender"), which is simpler and with less overhead.  


6.   Other research

Expect more Wake events. 
As they happen, use this step to diagnose which program is waking the PC. 
This report can be checked well-past the actual event but be aware the report is lost at reboot.

a.  Following the procedure in Step 1, search for and launch "CMD"  (DOS Command prompt).  Launch with Administrative rights.

b.  From the DOS prompt, type this command: 

powercfg -lastwake

Click for larger view

Review the cryptic report.  This may give hints to other programs which may be running in the background, or which may be in the Windows Task Schedule.  Things such as Acronis Backup or other such programs may be there.  How to resolve these varies by each software publisher.

If you see "USB eXtensible / Generic USB xHCI Host Controller", this is probably your mouse, disabled on a previous step.

This report has a long, yet volatile memory, surviving the last event, until the machine is rebooted.  Sadly, the report is not dated. 

My report detected the wake event documented above, in Step 4, which was subsequently fixed -- but the event remained in the report for several days.  Then, a few days later, the machine woke again.  The new report  showed:

Reason: Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Backup Scan'

>This one is harder to fix and I have not been willing to do this: See below, under "Advanced Disable Steps.

2022.12 Update:

See also this similar command, which shows all hardware devices allowed to wake your PC.  Typically finding Mouse and Keyboard:

powercfg -devicequery wake_armed

For example, my machine shows:
Razer BlackWidow V3  (mechanical keyboard)
HID Keyboard Device  (Windows keyboard driver)


7.  Other auto-startup programs may affect Wake events 

Programs in the Startup group, or in Services.msc, may or may not cause Sleep-Wake problems. 

This is documented as an advanced subject.

a. Locate Startup Programs

Start Menu, Settings (the Gear icon),
"Apps". 
Select Center-Nav [Startup].

Programs in this area likely unattended and "may" wake the PC at odd-hours.
Do not disable without researching consequences.

For example, on my computer I have disabled
* All Acronis Backup backend-processes, with the understanding I have to manually launch when needed.

* I also disabled these:

Intel Graphics Command Center (knowing I had access via the Control Panel)
Microsoft Edge (it will start when asked)
Microsoft Teams
Nuance Inbox Monitor (PDF tool)
Terminal

* Older computers may find Java updaters, and other vendor updaters. 
Consider disabling and running manually. 
Updaters are notorious for firing at odd times.


b.  Windows Services.msc

Windows also has (hundreds) of services which run in the background.

From the Start Menu, search, "Services.msc". 
Launch with administrative rights.

Just because the service is running, this does not mean it wakes the PC from sleep. 
Use care in this area and research before disabling.  With this said, I have not identified any common or obvious services.  Sort by "Status: Running" and look for any obvious software programs (typically application 'updaters').

When disabling a service, set the service to "Manual" (manual startup), acting as a flag so you know which ones you have touched.

For example,
I did find Microsoft SQL Server Express running on my development machine; this was set to manual.  On your computer, this service would be unlikely.

Also found two versions of Corel License Validation Service -- for older copies of WordPerfect. 
The ASUS motherboard updater would never find an update for a 4 year-old computer.



8 - Advanced Disable Steps

Even with the changes above, using Step 4's reporting, I found other values in the UpdateOrchestrator key where [ ] Wake was allowed to run. 

For example, the "Backup Scan" key is set to Wake, showing in the report like this:

Reason: Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Backup Scan'

-- but even with Admin rights, Task Scheduler would not allow an update to this event's schedule  (prompting for credentials did not work). 

Reviewing this task, it appears to trigger either Weekly or Monthly (note the Next Run Date).  This is not following the Scheduler's normal daily or weekly scheduled tasks!  I theorize: The Backup runs, then sets its own next schedule, only having one day in the schedule, and that day varies. 



9 - UpdateOrchestrator's other events can be disabled:
-----------------------------------------------------------------------------------------
(not recommended - these are nasty steps and are here for documentation)

I am reluctant to disable the these tasks using these steps, not yet knowing the consequences.
If these steps are used, it disables the services -- there is no way to simply turn off the [ ] Wake from Sleep setting.  However, it is safe to play with this idea as it is easily un-done.  DOS skills are required.)


a.  Create a folder, such as C:\data\downloads\Software\PSTools.
 
b.  Download PSExec (part of PSTools), from Microsoft (a .zip file).

https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
 
c.  Open the .ZIP.  Highlight all files.  Select "Copy"
     Paste all files in the ...\Software\PSTools folder


d.  From an administrative DOS prompt:

C:

CD\data\downloads\software\pstools
psexec.exe /acceptEula

If the Eula is declined (or some other problem), search the web for PSexec's EULA registry key.  Set the key-value to = 1.  Apologies, I neglected to document this properly.


e.  From this article: 

https://pastebin.com/tDaQwQ9L

Download the illustrated batch file.
Save to ..\Software\PSTools  folder.
Rename the long batchfile name to a shorter name, such as "disableWakeTimers.bat"


Comments about the Batch file:

  • Windows 10 only
  • Must run DOS prompt as Administrator
  • Requires PSTools from Microsoft:  Download steps, above


The edited batch file can lock itself (unheard-of with Notepad and yet it seems to happen)! 

With any editing changes, use Notepad to make the changes.  Close and save.  Then, re-open the Notepad .bat file and confirm the changes were actually saved!  If changes are lost, close the DOS Window, Close Notepad.  Re-open both, and re-edit/save the file.  This appears to release a file-lock.

f.  Instead of letting the batch file stop a half-dozen services, consider editing the batch, commenting-out all changes except for the "Backup Scan."  This way, you can test the process, and test restoring the system to its original settings. 

Edit the batch file:  REMark all lines except "Backup Scan":

schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Backup Scan"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\AC Power Download"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan Static Task"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\UpdateModelTask"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\USO_UxBroker"
Rem schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\AC Power Install"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Universal Orchestrator Idle Start"
REM schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Universal Orchestrator Start"


This is the line that is allowed to run (larger font):

schtasks /change /disable /tn "\Microsoft\Windows\UpdateOrchestrator\Backup Scan"

where all are "REMarked" except "Backup Scan"
Close and Save the file.  Reopen in Notepad to confirm changes.


g.  Save the changes to the batch file. 
Close Notepad.  Re-open the batch file and confirm changes were accepted.  (I had problems with this during testing)
 

h.  From the same Administrative DOS prompt:

c:
CD\data\downloads\software\pstools
disableWakeTimers.bat


i.  Confirm the changes:

     Start "Task Scheduler" as Administrator  (From Start, search "Task Scheduler")
     Launch as administrator  (if not many keys are hidden)

     Tunnel to ....\Windows\UpdateOrchestartor
     Review the Backup Scan task.  It should be disabled.
         Note:  it is not "[  ] Allow Wake"; instead, the entire task is disabled!


To re-enable:
--------------------------------------------------------------
Close the DOS prompt
Close Notepad
Re-open Notepad
Change "/disable" to "/enable"
Save Batch file; re-open to confirm.
From an Administrative DOS prompt, re-run the batch file.
Confirm with an Administrative run of "Task Scheduler"; note next scheduled date...

If satisfied with testing, continue and disable all:
------------------------------------------------------------------
Close, etc., all.  Edit the file, removing all REMarks.
Re-run the batch file to disable all tasks.

This is a less-than ideal.  "schtasks" does not have a command option to [ ] Allow Wake.
This is a lot of work, and some danger, just to stop these services from waking.  I have not experimented with forcing a new "Monthly" schedule -- fearing it would run monthly (which means far-fewer Wakes, but I fear it would stack multiple schedules for its next run.

Microsoft's documentation for "schtasks" can be found here:
https://docs.microsoft.com/en-us/windows/win32/taskschd/schtasks

----------------------------------------------------------------

PC does not wake from sleep

My desktop computer -sometimes- does not wake from sleep (even after a short sleep).  Moving the mouse or pressing a keyboard key does not wake the PC.  The (desktop's) power button is flashing, but all other lights are off -- indicating a sleep (not a power-down). 

This is a different issue than "waking from sleep unexpectedly."  

Clearly, this is an endemic problem with Windows, and perhaps some brands of motherboards, because thousands of posts on the Internet are begging for a solution.  I believe I have found the solution.

Possible solutions:
1.  Most important:  Update the motherboard's BIOS -- varies by manufacturer.

2.  In Device Manager, confirm the keyboard
Start, run:  "C:\Windows\System32\Devmgmt.msc".
Select "Run as administrator"

In Keyboards, properties, [Power Management]
confirm [x] Allow this device to wake the computer

3.  Adjust Power Plan

In Windows Settings (Gear icon)
Search: "Choose a power plan"
On Left-Nav, click "Choose what Power Buttons Do"
On center panel, click "Change settings that are currently unavailable" (assuming you do not have administrative rights)

In Power Options [Advanced Settings]
Locate USB Settings
Disable "USB Selective Suspend Setting"

4.  Look at Hibernation

The steps directly above fixed many, but not all, of the "won't wake from sleep" problems.  I still had an occasional problem where the PC would not wake after a 'hard' sleep, sometimes not waking after (midnight). 

Enabling Hibernation was a workaround when the steps above did not work all the time.  (Laptops should have Hibernation enabled, but many desktops do not.)  I realize this does not solve the problem; it masks the symptoms.  At least this stopped the PC from crashing and losing all your open files.

Especially if this is a desktop, 

a.  Click Start, immediately begin typing "Edit Power Plan"
b.  Click "Change Advanced Power Settings"
c.  Expand +Sleep; look for "Hibernate after"


d.  *If* "Hibernate after" is a choice, this step is not applicable.
d.  *If* "Hibernate after" is not an option on the expanded menu, do this:

Click Start, Type "CMD"
Open as "Administrator"
Type this command:  powercfg.exe /hibernate on

Return to the +Sleep menu
Set "Setting Minutes" = 240 Minutes (4 hrs) -- or set shorter; your preference

This changes behavior.  If the PC is asleep for more than 4 hours, it will go into hibernation.  All RAM is written to a temporary hibernation file at the root of the C: drive -- this is a large file, equal to RAM.  Once hibernated, the PC powers-off with a cold-shut-down. 

On a keyboard-wake event, or power button, the PC will cold-boot, passing through BIOS, etc.  Once Windows loads, it will be exactly at the same place you were before sleep (all active programs will still be active, just as you had left them). Waking from Hibernation takes a half-minute longer than a normal wake-from-sleep -- but at least the PC wakes.


5.  In BIOS  (experimental - I am still studying this idea and am unsure of the implications - 2024.09.  Update:  This change did not harm anything, but it did not help either.  Occasionally, the PC still would not wake from sleep -- most of the time it did.)

Cold-boot the PC, press (Del, F2, F10, etc., varies by manufacturer) to enter BIOS
in Advanced settings, look for a setting that sets USB Power Management to be controlled by BIOS instead of being controlled by the Operating System. 

For example, on an Asus motherboard, this setting is found here:
Advanced,  Advanced Platform Misc Configuration,
PCI Express Native Power Management
("Select [Enable] to perform active state power management (ASPM) operations in (the) OS" -- here, we are disabling this option)
- Change from "Enabled" to "Disabled"

F10 to save BIOS settings.


Comments on this article are welcome.


Related articles:
Windows 10 Administrative Account - Everyone should do this
Frankenputer - Building a new Home PC - much fun