1

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!

1
  • Including or excluding time spent in sleep/S3?
    – Anders
    Commented Jul 19, 2022 at 18:51

1 Answer 1

1

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

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