Run from command line (after saving file as ping test.vbs)cscript pingtest.vbs iptoping logfilenameIt will continuously run till you hit Ctrl+C to break it… Very useful for network testing.
hostIp = wscript.arguments(0)
logfilename = wscript.arguments(1)
Set fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Wscript.Shell")
' OpenTextFile Method requires a Const value
' (Over)Write = 2 Append = 8
Set logfile = fso.OpenTextFile(logfilename, 8, True)
shellstring = "%comspec% /c ping -t " & hostIP
Set oExec = Shell.Exec(shellstring)
wscript.echo "Ping Error log With Timestamp - Ctrl + C to halt"
Do While oExec.StdOut.AtEndOfStream <> True
pingline = Date & " " & Time & " " & oExec.StdOut.ReadLine
If InStr(pingline, "TTL=") = 0 Then
logfile.WriteLine(pingline)
End If
Loop