Get last boot/start time on Windows [duplicate]
How can I know when my computer running Windows 7 was last restarted?
I prefer a solution that doesn't involve searching the event log, but something like wmic
or maybe cmd
commands.
Solution 1:
systeminfo
command is almost right what you need. On English Windows 7 you can also do:
systeminfo | find /i "Boot Time"
Or with the help of WMIC:
wmic os get lastbootuptime
The main difference between Windows 7 and Windows XP that in Windows 7 Microsoft can show only last boot up time.
Also in Task Manager:
Solution 2:
One other way to do this is to use the following command-line that works both in Windows XP and Windows 7:
net statistics workstation
It has the advantage of being faster than the systeminfo
alternative while formatting the date (which wmic
does not). You also get a few other informations that can be useful if you are actually using this command for debugging a computer (since you are asking specifically for cmd
, I'm assuming you are not doing this programatically).
You can find more informations on the net statistics
command here: http://technet.microsoft.com/en-us/library/bb490714.aspx
Here is an example of the result (using a French copy of Windows 7 Pro SP1 x64, user-language doesn't matter much for the command-line):
(the computer name is purposely blurred)
More details on http://en.wikipedia.org/wiki/Uptime about the accuracy when determining system uptime.
Important note: this method determines when the computer was last booted, not its uptime. The 2 numbers will be different if you use sleep/hibernate.
Solution 3:
There's the LastBootUpTime
property of the Win32_OperatingSystem
class. You can use WMIC with this command:
wmic os get lastbootuptime
Or if you use Powershell, you can convert the time to something more readable than that annoying WMI datetime format:
Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastBootUpTime';expression={$_.ConvertToDateTime($_.LastBootUpTime)}}
Note that in later versions of PowerShell, you can also use Get-CimInstance, which will automatically return the value as a datetime:
Get-CimInstance -Class Win32_OperatingSystem | Select-Object LastBootUpTime
The only irritating thing is that Get-CimInstance will sometimes change the name of some system fields from WMI objects, such as __SERVER here. You'd have to use either CSName
or PSComputerName
, which seems to work for me.
Solution 4:
For Windows 10 users out there....
Solution 5:
Please note that as pointed out by Alex the /sleepstudy
command wasn't added until Windows 8.1. /systempowerreport might work instead.
Note that some of these other answers never worked for me, like searching the event-log for example was always missing some entries. @Florisz's answer is also correct in that regard. Here is my solution:
In an administrator cmd shell, run the following command:
powercfg /sleepstudy /output sleepstudy.html
Then open the file sleepstudy.html
in a browser. You will be greeted with amazingly organized statistics about shutdown/reboot/standby/hibernation from the last three days. (so, run periodically if you need)
An example of an output: (AFAIR, Showdown (Hybrid)
means fast startup)
Source / Documentation | Also related