2020-02-17

Windows 10 wakes from Sleep - Solution

How To: Windows 10/11 wakes from sleep.  Windows 10/11 computer wakes unexpectedly from Sleep.

This article was originally written for Windows 10.  Windows 11 is better behaved and has not experienced late-night wakes nearly as often. 

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


[2020.06 Update:  Steps 1 - 8 have worked very 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. 
If a [Power Management] tab, uncheck "[ ] Allow this device to wake the computer."

Benefit:  A bumped desk will not wake the computer.
Minor drawback:  Press any keyboard-key to wake 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.


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 uninstalling, 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 better, 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 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

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

powercfg -devicequery wake_armed



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 here as an advanced subject.

a. Locate Startup Programs

Start Menu, Settings (the Gear icon),
"Apps". 
Select Left-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 disabled Intel Graphics Command Center; knowing I had access via the Control Panel, and knowing I was using an external Video-card.

* Older computers may find Java updaters, and other vendor updaters. 
I would disable and run updates 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. 
Research before disabling services. Use care in this area.  With this said, I have not identified any common or obvious services.  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.  I have disabled services for other reasons, not documented here.

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


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 not a 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


Comments are welcome.


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