Re: uptime for Win XP?

Discussion in 'Python' started by Andrey Ivanov, Dec 12, 2004.

  1. >> I believe that "uptime" works from the console, but don't have a machine
    >> to check it with...


    > Doesn't work for me, but if you have win32all installed, you can get it
    > from Python:
    > >>> import win32api
    > >>> print "Uptime:", win32api.GetTickCount(), "Milliseconds"

    > Uptime: 148699875 Milliseconds


    MSDN recommends another approach. They say, that you should retrieve
    the value of "System Up Time" counter from HKEY_PERFORMANCE_DATA. In
    theory, you can do it without win32all, by using _winreg module. All
    you need is to know a counter index, which can be fetched from
    registry. On my system "System Up Time" counter has index "674", so
    Python code should look like this:

    >>> import _winreg
    >>> value, type_code = _winreg.QueryValueEx(_winreg.HKEY_PERFORMANCE_DATA, "674")
    >>> print "Uptime: %s miliseconds" % (value,)


    But in current implementation of _winreg it doesn't work. I've checked
    the sources and found that current implementation doesn't handle
    ERROR_MORE_DATA, which prevents it from retrieving any performance
    counters. I'm thinking of bug/patch submission.
     
    Andrey Ivanov, Dec 12, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oli Schwarz

    uptime in unix

    Oli Schwarz, Sep 19, 2004, in forum: Python
    Replies:
    8
    Views:
    4,551
    Heiko Wundram
    Sep 20, 2004
  2. Esmail Bonakdarian

    uptime for Win XP?

    Esmail Bonakdarian, Dec 11, 2004, in forum: Python
    Replies:
    24
    Views:
    12,421
    Peter Hansen
    Dec 13, 2004
  3. Tim Golden

    RE: uptime for Win XP?

    Tim Golden, Dec 13, 2004, in forum: Python
    Replies:
    1
    Views:
    354
    Peter Hansen
    Dec 13, 2004
  4. Andrey Ivanov

    Re: uptime for Win XP?

    Andrey Ivanov, Dec 13, 2004, in forum: Python
    Replies:
    2
    Views:
    414
    David Bolen
    Dec 13, 2004
  5. Krist
    Replies:
    6
    Views:
    785
    Arne Vajhøj
    May 7, 2010
Loading...

Share This Page