Skip to content

Instantly share code, notes, and snippets.

@x3rAx
Created March 18, 2018 13:58
Show Gist options
  • Save x3rAx/aab8ee721afae39e34bb778449665606 to your computer and use it in GitHub Desktop.
Save x3rAx/aab8ee721afae39e34bb778449665606 to your computer and use it in GitHub Desktop.
Commands to find out what can wake up windows / what the last wakeup reason was.

Who can wake up

Find out which devices are armed to wake up your pc:

powercfg -devicequery wake_armed

(source)

Last wake

Get information on last wake like the time or reason for wake up.

cmd /k wevtutil qe System /q:"*[System[Provider[@Name='Microsoft-Windows-Power-Troubleshooter']]]" /rd:true /c:1 /f:text

cmd /k - This opens a command session, executes the command that follows, and keeps the window open. Useful if you’re entering commands in a Run dialog; unnecessary if you already have an active command prompt.

wevtutil - Windows event log read utility.

qe - Query events …

System - … specifically from the system event logs.

/q:"..." - XPath-like query used to traverse the XML.

/rd:true - Direction, “true” shows latest first.

/c:1 - Number of results to return.

/f:text - Format output as text, which is fairly readable in this case. Could also opt for “XML”.

This simply returns the last event with a source name of ‘Microsoft-Windows-Power-Troubleshooter’. Skim through the result to verify that it’s a return from sleep event. If not, increase the number of results to return using the /c parameter.

This can also be accessed via the GUI using Start -> Run -> eventvwr -> Windows Logs -> System -> Find -> “Microsoft-Windows-Power-Troubleshooter”.

(source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment