Hello again (it's been a while)
How can I specify a (larger than the default) Time To Live (TTL) in vbScript (for PINGing more distant servers, e.g. Beijing to London!)? It's easy to do from the command line but I've not been able to find out how to set the TTL in my vbScript.
The code I have so far (and yes, I realise there is some redundancy here) is as follows:
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
How can I specify a (larger than the default) Time To Live (TTL) in vbScript (for PINGing more distant servers, e.g. Beijing to London!)? It's easy to do from the command line but I've not been able to find out how to set the TTL in my vbScript.
The code I have so far (and yes, I realise there is some redundancy here) is as follows:
Code:
Sub vbPING(strHost)
' Check that all arguments required have been passed.
if Ping(strHost) = True then
Wscript.Echo "Host " & strHost & " contacted"
Else
Wscript.Echo "Host " & strHost & " could not be contacted"
end if
End Sub
'---------------------------------------------------------
Function Ping(strHost)
dim objPing, objRetStatus
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
'WScript.Echo "Status code is " & objRetStatus.StatusCode
else
Ping = True
'Wscript.Echo "Bytes = " & vbTab & objRetStatus.BufferSize
'Wscript.Echo "Time (ms) = " & vbTab & objRetStatus.ResponseTime
'Wscript.Echo "TTL (s) = " & vbTab & objRetStatus.ResponseTimeToLive
end if
next
End Function
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]