- Stop Windows from randomly waking up from sleep.
- Stop Windows from killing your laptop by trying to install updates in your backpack.
- Stop Windows from waking you up at night by spinning your gamer fans to 100.
It's been a couple days since the last time the script has had to resleep. To recap:
- Use
powercfg -lastwake
to see why your pc is on. If itsPower Button
than you have a hardware issue (ex: laptop is getting jostled enough in your bag to wake up) - Ensure
powercfg /devicequery wake_armed
is empty - In
Task Scheduler Library
→Microsoft
→Windows
→UpdateOrchestrator
, make sure none of the tasks are set toWake the computer to run this task
- Disable wake timers in advanced power settings
- Disable hibernating after x minutes in advanced power settings as suggested by concrete_d
Simple script that sends your PC back to sleep if the wakeup source was not Power Button
.
For me, powercfg -lastwake
always reports the wake source as Power Button
regardless of if its opening the lid, mashing the keyboard, or doing exactly that.
If yours reports something different, make an issue/pull request and I'll add it as one of the acceptable wakeup reasons.
- Sleep your pc and wake it up again.
- Download the PsShutdown utility from Microsoft and add it to the %PATH%.
- Run
Test.bat
to make sure everything is ok. Failure to do so may result in a semi boot loop. Fixable, but obnoxious - Open the event viewer. Windows logs -> System -> Find the
Power-Troubleshooter
event indicating your PC woke up from sleep. - Right-click -> Attach task to this event.
- For the action, do
Start a Program
and browse forNeverWake.bat
- Check
Open the properties dialog when I click Finish
- Check
Run whether user is logged on or not
- Under conditions, uncheck
Start the task only if computer is on AC power
and hit OK. - Done. Your PC should now go back to sleep if a Windows service or any other program wakes it up.
- Enable all task history
- Click on an
Action Completed
event - View the exit code. 0 = nothing 1 = resleep
To fix this you either have to boot into safe mode or just power down and restart your pc completely (as a cold boot will not fire the power-troubleshooter event).