Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

4 Answers 4

up vote 37 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
2  
@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: howtogeek.com/72420/… 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)}}
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
5  
@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. msdn.microsoft.com/en-us/library/windows/desktop/… –  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: 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):

example

(the computer name is purposely blurred)


More details on http://en.wikipedia.org/wiki/Uptime about the accuracy when determining system uptime.

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 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 en.wikipedia.org/wiki/Uptime –  dnLL Dec 11 at 21:33

This is an expansion to @m0nhawk's answer

In PowerShell you could do

$date = wmic os get lastbootuptime | Select-String "\d\S+" | % { $_.Matches } | % { $_.Value }
[Management.ManagementDateTimeConverter]::ToDateTime($date)

Ridiculous how much code is needed for such a simple task

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.