How can I find out when Windows was last restarted?

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


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.


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.


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.