WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Last Reboot Time


Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = "Win32_OperatingSystem"
Instance = Service.InstancesOf(Class)
hEnum = ObjectCollectionOpen(Instance)
Obj = ObjectCollectionNext(hEnum)
LBT = Obj.LastBootupTime
LBT = StrSub(LBT,1,14)

ObjectCollectionClose(hEnum)
ObjectClose(Obj)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)

;convert WinBatch YmdHms format time to
;a human readable time. USA MM/DD/YYYY HH:MM:SS AMPM format

xyear= StrSub(LBT,1,4)
xmonth=StrSub(LBT,5,2)
xday= StrSub(LBT,7,2)
xhour= StrSub(LBT,9,2)
xmin= StrSub(LBT,11,2)
xsec= StrSub(LBT,13,2)

AMPM="AM"
if xhour>=13
xhour=xhour-12
AMPM="PM"
endif

newtime=strcat(xmonth,"/",xday,"/",xyear," ",xhour,":",xmin,":",xSec," ",AMPM)

Message ("I N F O","Last bootup was %newtime%")

Article ID:   W17319
File Created: 2007:07:03:14:29:28
Last Updated: 2007:07:03:14:29:28