1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objFile = objFSO.OpenTextFile("Liste_Machines.txt", ForReading, True)
If objFSO.FileExists("Histo_ping.txt") Then
Set objRes = objFSO.OpenTextFile("Histo_ping.txt", ForReading, True)
Histo = split(objRes.ReadAll, vbCrLf)
objRes.Close
Else
Dim Histo(1)
'Histo(0) = ""
End If
Set objRes = objFSO.OpenTextFile("Histo_ping.txt", ForWriting, True)
i = 0
Trouve = False
Ligne = ""
Do While objFile.AtEndOfStream <> True
Machine = objFile.ReadLine
'objRes.WriteLine (Machine)
Set WSHShell = CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping -n 1 -w 200 " & Machine)
PingResult = LCase(WshExec.StdOut.ReadAll)
wscript.echo PingResult
'if i <= UBound(Histo) And Histo(i) <> "" then
Set objRes2 = objFSO.OpenTextFile("Histo_ping.txt", ForReading, True)
Do While objRes2.AtEndOfStream <> True
Ligne = objRes2.ReadLine
Ligne = Left(Ligne, InStr(Ligne, " "))
If Ligne = Machine Then
Trouve = True
Wscript.echo Ligne
Wscript.echo Machine
End If
Loop
If Trouve = True Then
If InStr(PingResult, "octets=") Then
'Ping OK
objRes.WriteLine (Histo(i) & " --> OK")
Else
'Ping NOK
objRes.WriteLine (Histo(i) & " --> NOK")
End If
Else
If InStr(PingResult, "octets=") Then
'Ping OK
objRes.WriteLine (Machine & " OK")
Else
'Ping NOK
objRes.WriteLine (Machine & " NOK")
End If
End If
Trouve = False
i = i + 1
Loop
objFile.Close
objRes.Close |
Partager