I am new to vbscript. I am trying to get return value from a PingTest function below but it gives me an error at the function definition (I am using windows 10).
Function PingTest(hostName)
' Standard housekeeping
Dim colPingResults, objPingResult, strQuery
' Define the WMI query
strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & hostName & "'"
' Run the WMI query
colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery(strQuery)
' Translate the query results to either True or False
For Each objPingResult In colPingResults
If Not IsObject(objPingResult) Then
PingTest = False
ElseIf objPingResult.StatusCode = 0 Then
PingTest = True
Else
PingTest = False
End If
Next
colPingResults = Nothing
End Function
Dim output
output= PingTest("www.google.com")
WScript.Echo output