Enjoy...
@echo off
cls
set Address=google.com
set ThisDate=%date%A
echo %ThisDate%
:Loop
timeout /t 60
if "%date%" NEQ "%ThisDate%" (
echo %date% >>logfile.log
set ThisDate=%date%
echo %ThisDate%
)
echo %time% >>logfile.log
echo Pinging %Address%
%SystemRoot%\system32\ping.exe -n 1 %Address% | %SystemRoot%\system32\find.exe "TTL=" > NUL >> logfile.log
if %ERRORLEVEL% EQU 0 goto :Loop
echo Error Detected! >>logfile.log
echo Error Detected!
echo Trace route %Address% at %date% %time% >> logfile.log
tracert %Address% >> logfile.log
echo .
echo . >> logfile.log
goto Loop
pause Somehow, I got out of the loop
Of course, you can ping another site besides Google, and you can test more or less frequently than 60 seconds.
The log file grows forever unless you rename it, and looks a lot like this:
Thu 09/21/2017
15:55:28.70
Error Detected!
Trace route google.com at Thu 09/21/2017 15:55:40.74
Unable to resolve target system name google.com.
.
15:56:10.16
Error Detected!
Trace route google.com at Thu 09/21/2017 15:56:22.19
Unable to resolve target system name google.com.
.
15:56:52.15
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:57:22.17
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:57:52.13
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
15:58:22.11
Reply from 172.217.4.142: bytes=32 time=17ms TTL=54
15:58:52.18
Reply from 172.217.4.142: bytes=32 time=18ms TTL=54
Bryan Valencia is a contributing editor and founder of Visual Studio Journey. He owns and operates Software Services, a web design and hosting company in Manteca, California.
No comments:
Post a Comment