OLE – s – WMI Get Time and DatePlayer

This script uses OLE to access the Windows Management Instrumentation to get and display the current time and date.

 

newscript
' get the current date & time
dim myNewLine = chr(0x0a)
dim objLocator = CreateObject("WbemScripting.SWbemLocator")
dim objService = objLocator.ConnectServer(".", "root\cimv2")
dim objResults = objService .ExecQuery ("Select * from Win32_LocalTime")
' objService.Security_.ImpersonationLevel = 3
dim enumObj
FOR Each enumObj In objResults
olemap = enumObj
WITH enumObj
freestring = _
"Day: " & enumObj.Day & myNewLine _
& "Day Of Week: " & enumObj.DayOfWeek & myNewLine _
& "Hour: " & enumObj.Hour & myNewLine _
& "Minute: " & enumObj.Minute & myNewLine _
& "Month: " & enumObj.Month & myNewLine _
& "Quarter: " & enumObj.Quarter & myNewLine _
& "Second: " & enumObj.Second & myNewLine _
& "Week In Month: " & enumObj.WeekInMonth & myNewLine _
& "Year: " & enumObj.Year
end WITH

message = freestring
NEXT enumObj