473,698 Members | 2,451 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 3091
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
5261
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
4324
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
1886
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
12628
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
1653
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
2718
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
8676
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
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
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
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
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.