Navigation : DEVELOPPEMENT > VBS, WSH
TESTER SI UNE MACHINE EST PINGABLE
Ce petit script permet de vérifier qu'une machine répond au ping sur le réseau.
www.polyteknique.netLE SCRIPT SE RESUME A UNE FONCTION
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","","");
www.polyteknique.netTESTER LE SCRIPT
Pour tester la fonction, entrer par exemple :

    wscript.echo IsConnectable("192.168.0.1","","")



Rédigé le : 2005-06-14 15:13:01