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

User Sample Code

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

Get Local Time


strComputer = '.' ; '.' indicates local computer

;Windows 2000, Windows NT, and Windows 98/95:  Win32_LocalTime is not available.
;To convert WMI dates to FILETIME or VT_DATE format or to parse the date into component year, month, day,
;hours, and so on, you must write your own code.
objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!//" : strComputer : "/root/cimv2")
colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
ForEach objItem In colItems
    ;Check if Object is EMPTY
   type = ObjectTypeGet(objInstance)
   If type=="EMPTY" Then Break
    Data = "Day: " : objItem.Day : @LF
    Data = Data : "Day Of Week: " : objItem.DayOfWeek : @LF
    Data = Data : "Hour: " : objItem.Hour : @LF
    Data = Data : "Minute: " : objItem.Minute  : @LF
    Data = Data : "Month: " : objItem.Month : @LF
    Data = Data : "Quarter: " : objItem.Quarter : @LF
    Data = Data : "Second: " : objItem.Second  : @LF
    Data = Data : "Week In Month: " : objItem.WeekInMonth  : @LF
    Data = Data : "Year: " : objItem.Year
    Message("Win32_LocalTime", data)
Next

Article ID:   W17505
File Created: 2008:04:10:15:11:42
Last Updated: 2008:04:10:15:11:42