473,732 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uptime for Win XP?

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
Jul 18 '05 #1
24 3097
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


I believe that "uptime" works from the console, but don't have a machine
to check it with...
Jul 18 '05 #2
Tom Wesley 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

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.GetTic kCount(), "Millisecon ds"

Uptime: 148699875 Milliseconds

hth
greg
Jul 18 '05 #3
Tom Wesley wrote:
Esmail Bonakdarian wrote:
Is there a way to display how long a Win XP system has been up?
Somewhat analogous to the *nix uptime command.


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


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>uptime
'uptime' is not recognized as an internal or external command,
operable program or batch file.
Not here, at any rate. Maybe it's part of the Productivity Kit
thingy?

-Peter
Jul 18 '05 #4
IIRC, i think it's part of the powertools or IT Toolkit

Peter Hansen said:
Tom Wesley wrote:
Esmail Bonakdarian wrote:
Is there a way to display how long a Win XP system has been up?
Somewhat analogous to the *nix uptime command.


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


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>uptime
'uptime' is not recognized as an internal or external command,
operable program or batch file.
Not here, at any rate. Maybe it's part of the Productivity Kit
thingy?

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

--

Jul 18 '05 #5
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 | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #6
On Sun, 12 Dec 2004 14:25:28 +1000, Nick Coghlan <nc******@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 | nc******@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>pst at|wc
442 3350 27404

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

Regards,
Bengt Richter
Jul 18 '05 #7
Esmail Bonakdarian wrote:
Is there a way to display how long a Win XP system has been up?
Somewhat analogous to the *nix uptime command.


ugly, somewhat slow, and possibly locale dependent:

import os, re

def uptime():
return re.search(
"System Up Time:\s*(.+)", os.popen("syste minfo").read()
).group(1)

print uptime()

</F>

Jul 18 '05 #8
Bengt Richter wrote:
>>> 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']
[...]
There's got to be something leaner though.


I believe there is, though I can't guarantee this is a
valid approach:
import datetime
import os
def uptime(): .... t = os.stat('c:/pagefile.sys'). st_mtime
.... td = datetime.dateti me.now() - datetime.dateti me.fromtimestam p(t)
.... return td
.... print uptime()

12 days, 20:21:17.491000

(matches results of Bengt's and Fredrik's two approaches
two within a minute or so)

-Peter
Jul 18 '05 #9
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('syste minfo', 'r')
data = uptime.readline s()
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.
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5277
by: Oli Schwarz | last post by:
Hello, how can I read out the uptime of a unix system in python (Linux and *BSD). I have not found a uptime-function in the Library. Regards Oli
6
4327
by: MA | last post by:
Hi all! I know there is other newsgroups for webservices, but I don´t get any answers on those. I have developed a webservice that writeing and reading files in different folders. Question 1: I need to be able to stop this service by using a web interface
4
1893
by: Brian Henry | last post by:
does anyone know of an easy way to say how long has a specific system been up and running? I just need to get back the uptime of the servers on our network for a report, they are all in a Active Directory domain... needs to be in C# or VB.NET preferably. thanks!
4
12637
by: Dylan Parry | last post by:
Hi, I'm looking for a way to calculate the amount of time that Windows has been running since the last boot. Ideally I'd like to be able to create a DateTime object containing this value so that I can format it however I like. I've so far found a program called "uptime.exe" which is supplied by Microsoft on their website, but it outputs the uptime value as a string in the format "\\FRED has been up for: 5 day(s), 1 hour(s), 30
0
1657
by: streamkid | last post by:
hello.. could anyone please help me build a uptime script for openbsd? i tried phpsysinfo, it doesn't work (only uptime works, and that's around 15k days :p) i tried these: <?php $uptime_output = system("uptime", $uptime_output); print $uptime_output; ?>
8
2721
by: Guy Macon | last post by:
How to increase web server uptime with DNS failover: For illustration, let's start with some really bad hosting... Find four free web hosts that are each 90% reliable -- in other words they each are down on average one day out of ten. Use a failover DNS system with monitoring to switch servers if one fails. On average: One server will be down one day out of ten
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.