Calv1n
asked on
Checking Windows Server 2003 Reboot in Event Viewer
How can you tell that a server has been rebooted in Windows 2003 Server? Can you tell in Event Viewer? Or is their a better way? Thanks.
-Brian
-Brian
event viewer is the best way, just look for when the services all give a successful start
Yeah, You can check event view and there is information like when DHCP entered the running state ect..
Or you could Open Notepad. Paste the Below Code in. Save it as uptime.vbs - Now double click the file. This file will tell you how many hours the computer has been running for since last reboot.
' Check for computers last reboot
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
Dim uptime
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBoo tup)
dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBoo tup)
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
WScript.Echo uptime
Or you could Open Notepad. Paste the Below Code in. Save it as uptime.vbs - Now double click the file. This file will tell you how many hours the computer has been running for since last reboot.
' Check for computers last reboot
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
Dim uptime
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBoo
dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
uptime = dtmSystemUptime
Next
Function WMIDateStringToDate(dtmBoo
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
WScript.Echo uptime
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.