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
Hello Salmon Trout, its a nice script!!
Could you increase a code to add every one (or N) hour(s) in a log-file, a successful ping with address.
example:
05/01/2013 10:28:07 Reply from 74.125.234.39: bytes=32 time=41ms TTL=55
05/01/2013 11:28:07 Reply from 74.125.234.39: bytes=32 time=39ms TTL=55
etc...
I have a doubt:
I have used
www.google.com as a reference...
lping.vbs
www.google.com lping.log
If the Google IP change, your script will think that it is off-line?
I'm not sure if in your code, gets the Google IP at the start and always keeps the same!
It always checks the Google IP inside the loop or not?
Sorry-me about this, but Im not very familiar with VBScript!
and thank you for the script!!