RE: uptime for Win XP?

Discussion in 'Python' started by Tim Golden, Dec 13, 2004.

  1. Tim Golden

    Tim Golden Guest

    [Peter Hansen]
    |
    | Richie Hindle wrote:
    | > [Greg]
    | >
    | >>>>import win32api
    | >>>>print "Uptime:", win32api.GetTickCount(), "Milliseconds"
    | >
    | > Note that in the unlikely event of your Windows machine being up for
    | > longer than 2^32 ms (about 49 days), GetTickCount() will
    | wrap back to
    | > zero.
    |
    | The real solution, in spite of the dozen alternatives we've
    | now produced, seems to be to use the win32pdh library
    | to access the "System"-> "System Up Time" value.

    To add my twopence-ha'penny worth in, the recommended WMI
    technique is (apparently) to use the
    Win32_OperatingSystem.LastBootUpTime value:

    <code>
    import wmi
    for i in wmi.WMI ().Win32_OperatingSystem ():
    print i.LastBootUpTime
    </code>

    The time format is 20041202112313 with some --
    apparently unused -- sub-seconds, so you'd have
    to faff about a bit with the numbers, but it is
    at least usable.

    TJG

    ________________________________________________________________________
    This e-mail has been scanned for all viruses by Star. The
    service is powered by MessageLabs. For more information on a proactive
    anti-virus service working around the clock, around the globe, visit:
    http://www.star.net.uk
    ________________________________________________________________________
    Tim Golden, Dec 13, 2004
    #1
    1. Advertising

  2. Tim Golden

    Peter Hansen Guest

    Tim Golden wrote:
    > To add my twopence-ha'penny worth in, the recommended WMI
    > technique is (apparently) to use the
    > Win32_OperatingSystem.LastBootUpTime value:
    >
    > <code>
    > import wmi

    [snip code]

    Tim forgot to blow his own horn, so I will:

    http://tgolden.sc.sabren.com/python/wmi.html

    ;-)

    -Peter
    Peter Hansen, Dec 13, 2004
    #2
    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,498
    Heiko Wundram
    Sep 20, 2004
  2. Esmail Bonakdarian

    uptime for Win XP?

    Esmail Bonakdarian, Dec 11, 2004, in forum: Python
    Replies:
    24
    Views:
    12,358
    Peter Hansen
    Dec 13, 2004
  3. Andrey Ivanov

    Re: uptime for Win XP?

    Andrey Ivanov, Dec 12, 2004, in forum: Python
    Replies:
    0
    Views:
    437
    Andrey Ivanov
    Dec 12, 2004
  4. Andrey Ivanov

    Re: uptime for Win XP?

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

Share This Page