Here's my PING function (mostly ripped from somewhere else, I admit)
The first IF loop creates a false negative by appending the host name on first call of the function. Once a PING fails the function calls itself to try once more (the idea being to cancel out the possibility of a network blip) so the IF loop resets the strHost variable back to the original, correct, hostname during the testing.
Problem is even after calling itself with the correct strHostname it's still reporting a PING failure.
What am I doing wrong?
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
The first IF loop creates a false negative by appending the host name on first call of the function. Once a PING fails the function calls itself to try once more (the idea being to cancel out the possibility of a network blip) so the IF loop resets the strHost variable back to the original, correct, hostname during the testing.
Code:
Function Ping(strHost)
PingCount = PingCount + 1
if PingCount = 1 then
t_strHost = strHost
strHost = strHost & "1"
Else
strHost = t_strHost
PingCount = 0
end if
wscript.echo " pinging " & strHost
set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strHost & "'")
for each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
Ping = False
if PingCount = 1 then
Ping(t_strHost) ' Try again, just in case of a network 'blip'
end if
else
Ping = True
end if
next
End Function
Problem is even after calling itself with the correct strHostname it's still reporting a PING failure.
What am I doing wrong?
JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]