Home > OS >  How do I get Windows uptime via command prompt?
How do I get Windows uptime via command prompt?

Time:07-20

How do I get Windows uptime? systeminfo | find "System Boot Time:" shows the time it has been up since, but not for how long, that would need to be calculated separately. I need something like uptime -p on Linux but for Windows. If it's a shell command, then I'll run it via Python and grab the input. If there is a way in Python, what would be even better. (Task manager shows this in the Performance CPU tab). Thanks in advance!

CodePudding user response:

I'd leverage PowerShell, from the Command Prompt, if I wasn't already using Python!

This example outputs the number of whole minutes:

For /F %G In ('%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile "[TimeSpan]::FromMilliseconds([Math]::Abs([Environment]::TickCount)).TotalMinutes"') Do @Echo The System has been up for %~nG minutes

CodePudding user response:

You can use net statistics workstation,

It will show you Statistics since 7/17/2022 11:42:55 AM which is the system uptime.

  • Related