What is the simplest way to find out how long a computer is turned on Windows?
12 Answers
- Run command line
- Type Systeminfo
Find "System Boot Time"
Days: 10 Hours: 10 Minutes: 10 Seconds: 10
For shorter result you can use:
systeminfo | find "Boot Time"
-
9>systeminfo | find "Boot Time" – svandragt Jul 23 '09 at 09:18
-
2for me the simplest way now is > systeminfo | find "Up Time" – Juozas Kontvainis Jul 23 '09 at 09:29
-
4Doesn't work on Vista (use already included uptime.exe instead). – mwore Jul 23 '09 at 12:50
-
3Also note you can use this to query a remote machine as `systeminfo /S `*machinename*` | find "Up Time"` – GAThrawn Oct 14 '09 at 10:41
-
4On Windows 7, it shows "System Boot Time" but *not* "System Up Time". – Keith Thompson Dec 28 '11 at 22:20
-
2For Server 2003/XP use "Up Time", anything newer can use "Boot Time". – brndr Jun 10 '15 at 03:08
-
Just a note that in the "Boot Time" section the case does matter. I ran `systeminfo | find "Boot time"` which did not yield results. – tyelford Dec 03 '15 at 04:54
-
This hasn't worked for a very long time (many years). It'll return results that say a machine has been up for over 30 days when I know for a fact I turned it off last night and started it up this morning. Also, there is no "Up Time". Only "System Boot Time:". What OS had Up time? – Justin Emlay Dec 13 '18 at 22:40
-
This is of course working perfectly fine. What you are seeing, @JustinEmlay, is the result of “Fast Startup”. It is enabled by default and means your PC is not really shutting down most of the time, hibernating instead. – Daniel B May 03 '21 at 13:20
-
@Daniel B - it's been edited to be correct. As was stated many years ago "Up Time" no longer exists. Also, no, Fast Boot or Startup is disabled via Group Policy domain wide. – Justin Emlay May 04 '21 at 16:49
-
1Unfortunately the output is localized. For example, in German it''s called "Systemstartzeit". Any possibility to force English output? – Andi May 29 '21 at 14:11
there is great command line tool from Microsoft uptime.exe:
good thing with this tool is it works really fast.
Uptime [server] [/s ] [/a] [/d:mm/dd/yyyy | /p:n] [/heartbeat] [/? | /help]
server Name or IP address of remote server to process.
/s Display key system events and statistics.
/a Display application failure events (assumes /s).
/d: Only calculate for events after mm/dd/yyyy.
/p: Only calculate for events in the previous n days.
/heartbeat Turn on/off the system's heartbeat
/? Basic usage.
/help Additional usage information.
- 2,426
- 3
- 26
- 29
-
2this has been discontinued. [Archvie](http://web.archive.org/web/20100316211056/https://support.microsoft.com/kb/232243) and [download](http://web.archive.org/web/20091223110128/http://download.microsoft.com/download/winntsrv40/install/uptime_1.01/nt4/en-us/uptime.exe); also [sysinternals psinfo](https://superuser.com/a/103831) – john v kumpf Mar 05 '18 at 17:52
-
Open the command prompt and type:
net stats srv | find "Statistics"
Example output:
>net stats srv | find "Statistics"
Server Statistics for \\4IFS-SANDER
Statistics since 22/07/2009 10:14:14
Source (MS KB).
Edit: Actually this will tell you the date and time when the pc was up from, not the duration.
- 311
- 2
- 13
- 3,243
- 4
- 24
- 28
-
I'm not sure if this info is correct now, when I use MicTech's and KovBal's solution I get this: >systeminfo | find "Boot Time" System Boot Time: 23/07/2009, 02:22:27 – svandragt Jul 23 '09 at 09:17
-
On Vista it returns "Statistics since 1.1.1980 00:00:00" (use already included uptime.exe instead) – mwore Jul 23 '09 at 12:52
-
Returns bogus information just like systeminfo. It's returning a time that I know for a fact the machine last restarted. But then later that night it was turned off and turned back on this morning. Yet it's returning the last restarted time. 5 bucks says a month from now it'll report the uptime is a month long. Lots of machines on my network show many months of uptime which is all bogus. They're shut off at the end of the day. – Justin Emlay Dec 13 '18 at 22:45
-
@JustinEmlay are your machines sleeping, hibernated, or shut down? What version of Windows are you using? – mwfearnley Jul 02 '19 at 07:46
-
Windows 10 LTSC 2019. I found the issue. Windows 10 no longer shuts down nor restarts properly. By design. It uses some funky hybrid sleep mode. This also makes it so Windows doesn't properly reset "pending reboot" states. The option to turn it off was in Power Plan Options for one quick version of Windows 10 but then they removed it. Only way to turn it off is through registry. Anyway, this is why so many people are having issues. Local Machine - SYSTEM\CurrentControlSet\Control\Session Manager\Power - HiberbootEnabled - 0 – Justin Emlay Jul 02 '19 at 16:16
On Windows 7 / Windows Server 2008 and above, this information is displayed in task manager under the "Performance tab".
This can be quicker then using the command line and works in cases where you might have WMI issues preventing you from running systeminfo.
If you need to find this remotely, you could also run
systeminfo /s SERVERNAME | find "Time:"
from the command line.
- 310
- 3
- 9
-
On Windows 7 / SP1 and 2008 / R2, yes. Not on higher level OS (8, 8.1, 10) – BlueCompute Mar 10 '16 at 11:18
-
1I have just tested Windows 8.1 (Pro), 2012 and 2016 - what I had to hand. It is there on all three. You have to click "More details", and look on the Performance tab. – mwfearnley Jun 01 '17 at 07:47
-
And click on the CPU within the performance tab. Just bitten by this :-) – Cameron Oct 19 '17 at 14:35
-
Bogus information. I turned my machine on this morning yet it says my Up Time is over 13 days. – Justin Emlay Dec 13 '18 at 22:47
-
@BlueCompute it's always there in the "Performance" tab in Windows 8, 8.1 and 10 – phuclv Jun 10 '21 at 04:24
-
@JustinEmlay it's not bogus. It's because Windows 10 uses [fast startup](https://www.cnet.com/how-to/what-is-windows-10s-fast-startup/) and doesn't do real shutdown by default and just log out then hibernate the kernel space instead, so uptime is usually very large – phuclv Jun 10 '21 at 04:26
-
@phuclv nope, that's been disabled domain wide since day 1. Had no choice but to disable it since it fails to properly reset update reboot flags. This value does NOT always reset properly. – Justin Emlay Jun 11 '21 at 05:07
Following command gives last reboot time for a remote system:
systeminfo /s server_name | find "System Boot Time"
- 311
- 2
- 13
- 61
- 1
- 1
Yet another way:
C:\>wmic path Win32_OperatingSystem get LastBootUpTime
LastBootUpTime
20200908203723.500000+120
- 3,048
- 4
- 32
- 39
In windows 10, this is located in Task manager > Expand More Details Chevron > Performance > CPU > At the bottom, Up time.
- 7,984
- 2
- 19
- 32
Using SYSTEMINFO with PowerShell
For those who like using PowerShell, you can use the answer(s) above and wrap systeminfo in a PowerShell function to get a DateTime result for when the server last booted:
function Get-ComputerBootTime {
param($ComputerName = (hostname))
$SystemInfo = & systeminfo /s $ComputerName | Select-String "System Boot Time")
if($SystemInfo -match "[\d/]+,\s+\S+"){
return (Get-Date $matches[0])
}
}
And then call the function, for example:
[PS]> $BootTime = Get-ComputerUptime -ComputerName MYSERVER
To get the Uptime for the server, you compare with the current time:
[PS]> $UpTime = (Get-Date) - $BootTime
This is a TimeSpan, which includes properties such as TotalDays:
[PS]> $UpTime.TotalDays
14.1827364
- 311
- 2
- 13
-
don't use `systeminfo`. It's extremely slow. Use `Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime` or `Get-WmiObject win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}` instead – phuclv Jun 10 '21 at 04:30
Sometimes the uptime is dificult and user is not logged out and the two prety much coincide so I use this command to display the LOGON TIME
query USER
or shorter even:
quser
which prints something like:
C:\Users\eflorinescu>query USER
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
>eflorinescu console 2 Active 2+23:44 5/7/2018 8:25 AM
also even better using PowerShell
Get-ComputerInfo | select-object oslastbootuptime
- 2,946
- 7
- 34
- 45
-
1This is when the user logged into the PC which is really different than how long the PC has been on – gregg Jun 09 '21 at 16:52
-
@gregg yes you are right but is a quick check if you are never logged out the times are pretty similar, added also the correct PowerShell command – Eduard Florinescu Jun 09 '21 at 20:46
-
1Thanks, while this isn't exactly what was asked, `query user` is perfectly what I need! Cause I always log in instantly after powering on and I want to know this time. All the other solutions returns the real system boot up time which is (currently) a month ago, due to fast boot - I am not interested in that. – Nicolas Jul 11 '23 at 14:06
Anyone wanting the unix time (seconds since the epoch) that are using cygwin can try this:
date +%s -d "$(wmic path Win32_OperatingSystem get LastBootUpTime | grep -E '^[0-9]' | awk '{print substr($1,1,4) "-" substr($1,5,2) "-" substr($1,7,2) " " substr($1,9,2) ":" substr($1,11,2) ":" substr($1,13,2);}')"
- 2,213
- 2
- 20
- 28
In PowerShell either of the following commands will work
Get-WmiObject win32_operatingsystem |% {$_.ConverttoDateTime($_.lastbootuptime)}
(Get-CimInstance -ClassName win32_operatingsystem).lastbootuptime
Get-CimInstance is both shorter and more future proof, because Get-WmiObject and wmic have been both deprecated
You can also run (Get-WmiObject win32_operatingsystem).lastbootuptime but the output is less readable because it's a raw time string
- 26,555
- 15
- 113
- 235

