' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
function two(v)
    if v >= 10 then
        two = cstr(v)
    else
        two = "0" & cstr(v)
    end if
end function

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    lastBootTime = objOperatingSystem.LastBootUpTime
    lastBootTime = CDate(Mid(lastBootTime, 5, 2) & "/" & Mid(lastBootTime, 7, 2) & "/" & Left(lastBootTime, 4) & " " & Mid(lastBootTime, 9, 2) & ":" & Mid(lastBootTime, 11, 2) & ":" & Mid(lastBootTime, 13, 2))
    monthNumber = Month(lastBootTime)
    myMonthName = MonthName(monthNumber)
    Wscript.Echo("Last Reboot Time: " & myMonthName & " " & Day(lastBootTime) & ", " & Year(lastBootTime) & " " & two(Hour(lastBootTime)) & ":" & two(minute(lastBootTime)) & ":" & two(Second(lastBootTime)))
Next
