Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get Sytem Up Time information? 1

Status
Not open for further replies.

grofaty

IS-IT--Management
Jan 16, 2003
370
SI
Hi,

is there any command to only get "system up time" information without all of information 'systeminfo' command gives?

My system: Windows XP SP2

Thanks,
Grofaty
 
Hi there,

I use a program called Psinfo from
The command to only show uptime information is 'psinfo \\COMPUTERNAME uptime'

or just 'psinfo uptime' to query the machine you are on

or 'psinfo \\* uptime' for all machines in the workgroup/domain

It's very useful!

'When all else fails.......read the manual'
 
Not sure if this is much help to you but if you do a Ctrl Alt Delete it will show you the last time you logged into the computer
 
Hi,
is there any way without installing a new software. This is a server computer and I am not allow to install any software.

Now I use command:
systeminfo | find "System Up Time:" > uptime.txt

Info from file uptime.txt is used by other program to display a information on web.

I am just looking for any command to display the same information in faster (performance) time.

Thanks,
Grofaty
 
psinfo doesnt install as such, you just extract the .exe and run from a command line

Have you tried the command without the '> uptime.txt' bit?

'When all else fails.......read the manual'
 
Microsoft's Uptime Reliability and Availability Information Tool doesnt install as such, you just extract the .exe and run from a command line.
 
hats off for the extreme copy and paste reply lol

'When all else fails.......read the manual'
 
Hi,
sysadm doesn't allow any software no mather is there is installed or just 'extracted' (copied). :(

So I have to use existing software. This is not so big problem, so if no other solution is found then 'my solution' will be sufficient.

Thanks,
Grofaty
 
Grofaty,

You should be able to use the following script to show 'uptime' on either a local or remote PC/Server, without installing anything.

Code:
strComputer = "."
'Note: Use "." above for the local computer or replace the "." with either the computername (local subnet)
'or an IP address (different subnet) of a remote PC

On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer _
        & "\root\cimv2")

If Err.Number = 0 Then
     On Error Goto 0
     strQuery = "select * from Win32_PerfRawData_PerfOS_System"
     Set colObjects = objWMIService.ExecQuery(strQuery)

     For Each objWmiObject In colObjects
       intPerfTimeStamp = objWmiObject.Timestamp_Object
       intPerfTimeFreq = objWmiObject.Frequency_Object
       intCounter = objWmiObject.SystemUpTime
     Next

     ' Calculation in seconds:
     ' Calculations for Raw Counter Data:PERF_ELAPSED_TIME
     ' [URL unfurl="true"]http://msdn.microsoft.com/library/en-us/perfmon/base/perf_elapsed_tim...[/URL]
     iUptimeInSec = (intPerfTimeStamp - intCounter)/intPerfTimeFreq
     WScript.Echo "Uptime in seconds: " & iUptimeInSec \ 1

     ' Convert the seconds
     sUptime = ConvertTime(iUptimeInSec)
     WScript.Echo "Uptime: " & sUptime

Else
     Wscript.Echo "Could not connect to computer with WMI: " _
         & strComputer
End If

Function ConvertTime(seconds)
     ConvSec = seconds Mod 60
     ConvMin = (seconds Mod 3600) \ 60
     ConvHour =  (seconds Mod (3600 * 24)) \ 3600
     ConvDays =  seconds \ (3600 * 24)
     ConvertTime = ConvDays & " days " & ConvHour & " hours " _
                 & ConvMin & " minutes " & ConvSec & " seconds "
End Function

Just copy the code above (by MVP Guru Torgeir Bakken) then paste it into a Notepad file then save it as something like 'uptime.vbs'. If necessary, you may need to amend the first line of the script to point to any remote PC/Server that you are checking uptime for.

Hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top