Trying to return string from Function results in Object required error.
Running this code on Windows 2003. Note: on w2k3, Win32_OperatingSystem
does
not support the =@
singleton which is why we're using For Each ... / Exit Function
Function GetLocalTime()
Dim wmi, itm
Set wmi = GetObject("winmgmts:root\cimv2")
For Each itm in wmi.ExecQuery("SELECT * FROM Win32_OperatingSystem")
' NEXT LINE THROWS 'Object required' error
GetLocalTime = itm.LocalDateTime
Exit Function
Next
End Function
Dim started : Set started = GetLocalTime
WScript.Echo "started " & started