Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 82 down vote accepted

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:

enter image description here

share|improve this answer
Also , is there any accumulative list of last resets ? – Royi Namir Dec 24 '12 at 14:40
@RoyiNamir: With some googling list of reboots (looks very similar): Get-EventLog -LogName System | where { ($_.InstanceId -bAnd 0xFFFF) -eq 6006 } – m0nhawk Dec 24 '12 at 15:08
it is powershell ..... ? – Royi Namir Dec 24 '12 at 15:10
You can also see the list in event viewer like so:… I'm sure you can query this with PowerShell's Get-WinEvent but I haven't investigated that at all. – Bacon Bits Dec 24 '12 at 15:11

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 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.

share|improve this answer
20121217175810.414696+120 I think I need damn good calculator to calc time – Royi Namir Dec 24 '12 at 14:43
@Royi Yeah, WMI timestamps are stupid. It's a CIM_DATETIME, which is the format required by the standard. It's yyyymmddHHMMSS.mmmmmmsUUU, using 24 hour time. Here, your last reboot time is Dec 17, 2012 at 5:58 PM.… – Bacon Bits Dec 24 '12 at 14:53
Handy 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) – camster342 Oct 20 '13 at 22:22

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:

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 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.

share|improve this answer
any 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 – Anthony Shaw Dec 11 '14 at 20:31
It does differ for aobut 40 seconds on my computer too. I don't have any idea why it's not exactly the same, I guess the service just boots a little bit latter. Some interesting info on – dnLL Dec 11 '14 at 21:33
It 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, and systeminfo 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. – Cameron Feb 12 at 6:05
Thank 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. – dnLL Mar 10 at 15:08

This is an expansion to @m0nhawk's answer

In PowerShell you could do

$date = wmic os get lastbootuptime | Select-String "\d\S+" | % { $_.Matches } | % { $_.Value }

Ridiculous how much code is needed for such a simple task

share|improve this answer

On Windows 7 I prefer

net statistics workstation

WMIC doesn't take into account sleep time, and I leave my workstation locked up at work sleeping during the week, ready to wake up the next day.

share|improve this answer

yet another way in a batch file to get boot time with wmic but in human readable form :

for /f %%a in ('WMIC OS GET lastbootuptime ^| find "."') DO set DTS=%%a
set BOOTTIME=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%  %DTS:~8,2%:%DTS:~10,2%

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .