Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem This batch file pings an IP and logs whether it was successful or not
- rem If ping fails, tracert will be run to help diagnose
- rem These are the values used throughout the batch file. Change them here if you like.
- set myIP=4.2.2.2
- set myFile=.\Internet.txt
- set myTimeout=5
- :START
- @echo off
- ping -n 4 %myIP% -w 1000 | findstr /r /c:"[0-9] *ms" >nul
- if %errorlevel% == 1 (
- echo %DATE% %TIME% Internet offline
- echo %DATE% %TIME% Internet offline >> %myFile%
- echo Beginning Traceroute!
- echo Beginning Traceroute >> %myFile%
- tracert %myIP% >> %myFile%
- ) else (
- echo %DATE% %TIME% Internet online
- echo %DATE% %TIME% Internet online >> %myFile%
- )
- rem You can change this timeout but by default it waits 5 seconds between pings
- Timeout /t %myTimeout%
- @set errorlevel = 0
- GOTO START
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement