tags:

views:

368

answers:

5

Does Windows XP (and up) store how long it has been...

  • ...since the system booted?
  • ...running since install?
  • ...in hours/minutes since current used logged on?
  • ...in total hours the user has been logged on?

Thanks.

A: 

You can see when the system started by typing the following into a command prompt

net statistics workstation

You'll get output like this

Workstation Statistics for \\LAPTOP


Statistics since 8/31/2009 8:50:10 PM
A: 

psinfo from Sysinternals

benPearce
+1  A: 

GetTickCount() does what you want, though it wraps-around every 49 days or so. So, yeah, use GetTickCount64().

jeffamaphone
The only problem is that this one shows the time since the OS itself started, not since the user has logged in.
Franci Penov
+2  A: 

You can use the LsaGetLogonSessionData to get the data about a particular logon session, including the time the session was started. To call that method you need a LUID - a logon session ID. You can get the list of current logon sessions LUIDs using LsaEnumerateLogonSessions.

If you are looking for the data for a particular user, you can look at the UserName member of the SECURITY_LOGON_SESSION_DATA structure returned by LsaGetLogonSessionData.

Edit: To get the time since the system was started, use GetTickCount64(), as @jeffamaphone mentioned.

The others you can calculated from the difference between the SECURITY_LOGON_SESSION_DATA.LogonTime and the current time.

Franci Penov
A: 

On the terminal run systeminfo

Example:

C:\WINDOWS>systeminfo

Host Name:                 ...
OS Name:                   Microsoft Windows XP Professional
OS Version:                5.1.2600 Service Pack 2 Build 2600
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          ...
Registered Organization:   ...
Product ID:                ...
Original Install Date:     17/04/2009, 10:23:23 AM
System Up Time:            0 Days, 0 Hours, 51 Minutes, 11 Seconds
System Manufacturer:       Dell Inc.
(etc...)

I believe there may be other ways also to find such info. For example, PCWizard shows some more detailed info about install date, boots since install, uptime, time since logon, etc.