uptime for Win XP?

Brad Tilley rtilley at vt.edu
Sun Dec 12 16:57:28 EST 2004


Esmail Bonakdarian wrote:
> Hi,
> 
> Is there a way to display how long a Win XP system has been up?
> Somewhat analogous to the *nix uptime command.
> 
> Thanks,
> Esmail

Just run the built-in Windows utility 'systeminfo' from a cmd prompt. 
Python can call 'systeminfo' like this:

import os

uptime = os.popen('systeminfo', 'r')
data = uptime.readlines()
uptime.close

for line in data:
    if line contains "System Up Time":
       print line

Please note that 'systeminfo' is only present on Windows XP PRO and 
Windows Server 2003... Windows XP HOME does not have this command.



More information about the Python-list mailing list