[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 16799
  • Last Modified:

how do i check the uptime of a windows 2003 server?

how do i check the uptime of a windows 2003 server?
1 Solution
Start > Run
Type ' cmd'

use the command ' systeminfo'
At the top you will see system uptime.
Here is a script that can get all the machine names that are in a file.txt " Create a file names "Devices.txt" and put in the files in there

' declare constants
Const ForReading = 1

On Error Resume Next

'get current computer display resolution so we can position windows
Set objWMIService = GetObject("winmgmts:\\\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT PelsHeight,PelsWidth FROM Win32_DisplayConfiguration", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
     localHeight = objItem.PelsHeight
    localWidth = objItem.PelsWidth

'set up explorer progress window
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"  
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Height = 200
objExplorer.Left = (localWidth-400)/2
objExplorer.Top = (localHeight-200)/2
objExplorer.Document.Title="Uptime Audit Tool"
objExplorer.Visible = 1            

'open FSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

' verify devices.txt exists
If objFSO.FileExists("devices.txt") Then
     Set objFolder = objFSO.GetFile("devices.txt")
     'display visual alert and exit script on error
     Wscript.Echo "Fatal Error: devices.txt cannot be found."
End If

' obtain device list from devices.txt
Set objDeviceFile = objFSO.OpenTextFile("devices.txt", ForReading)

'create output file
strOutputFile = "UptimeAudit.htm"
Set objAuditLog = objFSO.CreateTextFile(strOutputFile, 1)

'start writing output
objAuditLog.WriteLine "<html>"
objAuditLog.WriteLine "<head>"
objAuditLog.WriteLine "<title>Uptime Audit Report</title>"
objAuditLog.WriteLine "<meta content='Uptime Audit Report'>"
objAuditLog.WriteLine "</head>"
objAuditLog.WriteLine "<body>"

Do Until objDeviceFile.AtEndOfStream
     strComputer = objDeviceFile.Readline

    objExplorer.Document.Body.InnerHTML ="<font size=4 color=#0000FF><b>Connecting to " & strComputer & "</b></font>"
     Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv" )

     Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
     if Err.Number <> 0 Then
    objExplorer.Document.Body.InnerHTML ="<font size=4 color=#0000FF><b>Connect to " & strComputer & "failed</b></font>"    
     objAuditLog.WriteLine "<font color=#990000 size=4>Could not connect or access WMI on " & strComputer & "</font><br>"

      For Each objOS in colOperatingSystems
          dtmBootup = objOS.LastBootUpTime
          dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
          dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
          if dtmSystemUptime <= 1440*5 then
            objAuditLog.WriteLine "<font color=#0000FF size=4>" & strComputer & " has been down in the last five days<br>"
            objAuditLog.WriteLine "<font color=#0000FF size=4>" & strComputer & " has NOT been down in the last five days<br>"
        end if

     End If


     objAuditLog.WriteLine "</body>"
     objAuditLog.WriteLine "</html>"

     'close table and log file
     strDisplayText = "System information retrieved."
     objExplorer.Document.Body.InnerHTML = strHTMLStart & strDisplayText & strHTMLEnd


     Set objWSHShell = CreateObject("WScript.Shell")


Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
        Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
            & " " & Mid (dtmBootup, 9, 2) & ":" & _
                Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function
Farhan KaziSystems EngineerCommented:
Click Start -> Run -> Cmd.exe
SystemInfo |FIND /I "System Up Time"
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

... or just run 'uptime' available from Microsoft at no charge -

Lee W, MVPTechnology and Business Process AdvisorCommented:
Two other methods:

1.  Check the statistics of the server or workstation service.  These services are RARELY if ever restarted, so it's generally a reliable method:

NET STATISTICS WORKSTATION or NET STATISTICS SERVER - the top line indicates when the service started.

2.  Check your event log - System Log - for source EventLog and ID 6009.  Whenever the system reboots, it logs this event.
There is also an event recorded in the System event log at 12 noon every day telling you the uptime of the system in seconds. (ID 6013) If you need to filter on events then the Event Source is simply the eventlog, or just do it on event ID.


Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now