uptime for Win XP?

Bengt Richter bokr at oz.net
Sun Dec 12 03:11:28 EST 2004


On Sun, 12 Dec 2004 14:25:28 +1000, Nick Coghlan <ncoghlan at iinet.net.au> wrote:

>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
>
>It's included in the output of the 'systeminfo' command. That command is fairly 
>slow, though (since it displays a lot more than just the up time)
>
>There's also info about the 'uptime' utility here:
>http://support.microsoft.com/kb/q232243/
>
>I don't know if that works for XP.
>
>Cheers,
>Nick.
>
>-- 
>Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
>---------------------------------------------------------------
>             http://boredomandlaziness.skystorm.net

 >>> import os
 >>> [x for x in os.popen('pstat') if 'uptime' in x.lower()]
 ['Pstat version 0.3:  memory: 327080 kb  uptime:  4 15:44:16.696 \n']

That is, if pstat.exe is on your system and path. It comes with various sdk's
and Visual studio stuff. Check tools subdirectory under the latter.
Pstat prints a snapshot of pmon plus drivers info which means info about every process
and thread running as well as drivers loaded, so the above threw away a lot of lines to get the one:

[23:38] C:\pywk\clp>pstat|wc
        442       3350      27404

;-)
There's got to be something leaner though.

Regards,
Bengt Richter



More information about the Python-list mailing list