Function IsConnectable(sHost,iPings,iTO)
' sHost est un nom de machine ou une IP
' iPings est le nombre de pings à effectuer
' iTO est le timeout de la commande ping
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
Set oShell = CreateObject("WScript.Shell")
Set oExCmd = oShell.Exec("ping -n " & iPings & " -w " & iTO & " " & sHost)
Select Case InStr(oExCmd.StdOut.Readall,"perte 0%")
Case 0 IsConnectable = True
Case Else IsConnectable = False
End Select
End Function
ret = IsConnectable("172.16.87.6","","");
Pour tester la fonction, entrer par exemple :
wscript.echo IsConnectable("192.168.0.1","","")