Answer the question
In order to leave comments, you need to log in
We write Ping to a file. Which Errorlevel to choose?
I wrote the following script in a .bat file:
@Echo Off
:begin
echo Date %date:~0,2%-%date:~3,2%-%date:~6,4% Time%time%>> %DATE%.txt
ping -n 5 192.168.1.100>> %DATE%.txt
if errorlevel 1 echo ALARM Date %date:~0,2%-%date:~3,2%-%date:~6,4% Time%time% >>"%date%ALARM_192.168.1.100.txt"
ping -n 30 127.0.0.1 >nul
echo ********************************************************>> %DATE%.txt
goto begin
Answer the question
In order to leave comments, you need to log in
I did this:
2>nul ping %IP% | 1>nul 2>&1 findstr "TTL" || (echo.Error
) in the ping output, we are looking for an occurrence of the TTL substring, if not found, then an error.
This works more reliably than checking errorlevel pinga.
The host is unreachable, this is ICMP Type 3
A The timeout for the request has been exceeded - this is no response at all ..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question