简体   繁体   中英

How do I get Windows uptime via command prompt?

How do I get Windows uptime? systeminfo | find "System Boot Time:" 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!

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

You can use net statistics workstation ,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM