| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 
 | Const ForReading = 1, ForWriting = 8
Dim oFso
Dim Fichiercsv, Message, Date_Heure, Adresse
Set oFso = CreateObject("Scripting.FileSystemObject")
 
Adresse = "10.33.243.160"
Fichiercsv = "R:\06 - INFORMATIQUE\G - PROJETS\Ping\IP_test.csv"
 
If oFso.FileExists(Fichiercsv) = False then oFso.CreateTextFile(Fichiercsv)
 
Message = now
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & Adresse & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then
Message = Message & ";Ping  " & adresse & ";succes;Temps de réponse: " & objStatus.ResponseTime & "ms" & vbcrlf
Else
Message = Message & ";Ping  " & adresse & ";echec" & vbcrlf
End if
Next
 
Set myfile = oFso.OpenTextFile(Fichiercsv, ForWriting) : myfile.Write(Message) : myfile.Close |