WMI LastBootUpTime wrong value
From: Text (mas_at_mas.com)
Date: 04/22/04
- Next message: Joe Earnest: "Re: Variable function name"
- Previous message: dpn: "Re: WSH - How execute security patch on remote NT4 Workstation.."
- Next in thread: Richard Mueller [MVP]: "Re: WMI LastBootUpTime wrong value"
- Reply: Richard Mueller [MVP]: "Re: WMI LastBootUpTime wrong value"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 22 Apr 2004 11:26:54 -0400
I am working on an uptime script for servers and can't seem to get an
accurate time when I query objItem.LastBootUpTime from
Win32_OperatingSystem. It always 4:00 hours too early.
If the server logs and uptime.exe say the server is upt 4 hours. My wmi
reports the server came up 4 hours before that. I am on eastern time. I
guess its my off set from UTC time, but I can't figure out how to deal with
that
Dim objWMIService
Dim colItems
Dim endfile
Set fs = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem",,48)
For Each objItem in colItems
WScript.Echo "LastBootUpTime: " & objItem.LastBootUpTime
WScript.Echo "LocalDateTime: " & objItem.LocalDateTime
strvalue1 = dtparse(objItem.LastBootUpTime)
strvalue2 = dtparse(objItem.LocalDateTime)
WScript.Echo strvalue1 & " " & strvalue2 & " strvalues"
intday = DateDiff("d", strvalue1, strvalue2)
inthour = DateDiff("h", strvalue1, strvalue2)
intmin = DateDiff("n", strvalue1, strvalue2)
WScript.Echo (inthour \ 24) & " day(s) " & (inthour Mod 24) & " hours " &
(intmin Mod 60) & " minutes"
Next
Function dtparse(strvalue) 'this function parses the Time into a readable
format.
stryear = Left(strvalue, 4)
strmonth= Mid(strvalue, 5,2)
strday = Mid (strvalue, 7,2)
strhour = Mid(strvalue, 9,2)
strmin = Mid(strvalue, 11,2)
strsec = Mid(strvalue, 13,2)
strmsec = Mid(strvalue, 16,6)
strtz = Right(strvalue, 4)
strdate = strmonth & " " & strday & ", " & Stryear
strtime = strhour & ":" & strmin & ":" & Strsec
dtparse = CDate(strdate & " " & strtime)
End Function
- Next message: Joe Earnest: "Re: Variable function name"
- Previous message: dpn: "Re: WSH - How execute security patch on remote NT4 Workstation.."
- Next in thread: Richard Mueller [MVP]: "Re: WMI LastBootUpTime wrong value"
- Reply: Richard Mueller [MVP]: "Re: WMI LastBootUpTime wrong value"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|