How can I find out when Windows was last restarted?
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)
Related videos on Youtube
Royi Namir
Updated on September 18, 2022Comments
-
Royi Namir almost 2 years
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 maybecmd
commands. -
Royi Namir over 11 yearsAlso , is there any accumulative list of last resets ?
-
Royi Namir over 11 years
20121217175810.414696+120
I think I need damn good calculator to calc time -
m0nhawk over 11 years@RoyiNamir: With some googling list of reboots (looks very similar):
Get-EventLog -LogName System | where { ($_.InstanceId -bAnd 0xFFFF) -eq 6006 }
-
camster342 over 10 yearsHandy bonus of using the get-wmiobject method is it makes it trivial to get boot times of remote computers too. Just add "-computer <computername>" to the command (before the pipe)
-
Anthony Shaw over 9 yearsany idea why this doesn't read the same as using systeminfo or wmic... it's probably negligible, but it differs on my system by over 2 minutes
-
Cameron over 8 yearsIt differs by over nine months on mine :-) This is the only correct answer. It gives the actual datestamp of the last boot (or when whatever associated service started after bootup, so very close to it), whereas
wmic
, Task Manager, andsysteminfo
all seem to count backwards from the current time by the number of ticks the PC has been running. But if you put your computer to sleep (or hibernate) a lot, like I do, the actual total running time is much less than the time since the last boot (only thirty days in my case over the last several months), throwing off that calculation completely. -
dan over 8 yearsThank you @cameron, I added a note at the end of my answer. The original question was really about when the computer started and not its uptime, so that's an important detail. Wikipedia does somewhat mention the difference in the uptime article I linked.
-
calin over 7 years"Boot Time" appears to be lying. It's telling me last Friday but I know I've shut down my computer several times since then.
-
user over 7 yearsThis answer would be better if it included an explanation of how the
set BOOTTIME
works. -
Markus Mitterauer about 7 yearsBe aware that
systeminfo
is localised. So"Boot Time"
is only true for english versions of Windows. -
oldmud0 about 7 yearsThat isn't really the last "boot" time - it's the time that the Server or Workstation service started, depending which one you query stats for. Since these don't ever stop during a regular Windows session, it's a convenient approximation of last boot time.
-
Sopalajo de Arrierez over 6 yearsLocalization for spanish-speakers:
systeminfo | find /i "tiempo de arranque"
for the spanish version of Windows. -
David Ferenczy Rogožan about 6 yearsThis shows you the uptime (i.e. how long the system is running) not the time when the system has been started as OP asked.
-
tbc0 almost 6 yearsDidn't work for me on Windows 10. Not even as admin. See snag.gy/HcEn8j.jpg
-
tbc0 almost 6 yearsTrue, but this is still useful.
-
tbc0 almost 6 yearsI don't think so. At least on Windows 10, when I checked, the swap file time was newer than boot time.
-
tbc0 over 5 yearsToday my Windows 10 notebook is showing a bogus uptime. I shut it down last night, powered it on less than an hour ago, and Task Manager says it's been up for 5:19:40:10.
-
tbc0 over 5 yearsThis is what I was looking for on Windows 10! I don't reboot, I normally shutdown. LastBootTime only refers to reboots on Windows 10.
-
Daniel Hayes over 5 yearsWindows 10 does not actually shut down when shut down, I forget why exactly. However, if you want the uptime timer to reset you must restart.
-
schoetbi about 5 years
systeminfo | find /i "Systemstartzeit"
for german -
klutt over 4 years@DawidFerenczyRogožan Current time - Uptime = The time OP asks for, right?