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

Posted on 2007-10-16
Last Modified: 2008-10-21
how do i check the uptime of a windows 2003 server?
Question by:go95
    LVL 15

    Accepted Solution

    Start > Run
    Type ' cmd'

    use the command ' systeminfo'
    At the top you will see system uptime.
    LVL 11

    Expert Comment

    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
    LVL 26

    Expert Comment

    Click Start -> Run -> Cmd.exe
    SystemInfo |FIND /I "System Up Time"
    LVL 9

    Expert Comment

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

    Expert Comment

    by:Lee W, MVP
    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.
    LVL 58

    Expert Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I have never ceased to be amazed how many problems you can encounter on a fresh install of a Windows operating system.  This is certainly case in point& Unable to complete ANY MSI installation.  This means Windows Updates are failing and I can't …
    by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now