Home » Questions » Computers [ Ask a new question ]

How to find out uptime on Windows?

How to find out uptime on Windows?

What is the simplest way to find out how long a computer is turned on Windows?

Asked by: Guest | Views: 271
Total answers/comments: 5
bert [Entry]

"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"""
bert [Entry]

"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."
bert [Entry]

"If you have the Windows Server 2000 or 2003 resource kits try

srvinfo -ns [\\\server] | Findstr ""Time""

Note: Srvinfo.exe will not run on a 64-bit versions of Windows, due to it being 16-bit."
"If you have the Windows Server 2000 or 2003 resource kits try

srvinfo -ns [\\\server] | Findstr ""Time""

Note: Srvinfo.exe will not run on a 64-bit versions of Windows, due to it being 16-bit."
bert [Entry]

"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"
bert [Entry]

"Yet another way:
C:\>wmic path Win32_OperatingSystem get LastBootUpTime
LastBootUpTime
20200908203723.500000+120"