I wanted a windows service I’m building to run overnight. So I changed my power options and set my computer to never sleep. Started the windows service and went home. This morning I found my computer sleeping and was curious if someone manually put it to sleep after I left. Is there a log file or some way to find the last time my computer went to sleep? I’m using a Windows 7 operating system.
Share
Have you consulted Event Viewer? To start Event Viewer by using a command line
Information about scheduled / unscheduled sleeps and reboots should be found by expanding the tree view in the left plan to Event Viewer > Windows Logs > System.
You can also get the last boot time by using the WMI service object to query the LastBootUpTime property of the Win32_OperatingSystem class. Note that the returned date is in WMI date time format which you’ll need to use tools to convert into a human readable date.
Here’s a VBScript sample:
Here’s a PowerShell example:
Here’s a Command Prompt example (uses PowerShell):
References: