I want to check internet connection, when it fails I want to set %internet%
to not connected. And if it works to connected
.
echo ch
Another option...
ping -n 2 -w 700 10.11.1.1 | find "bytes="
IF %ERRORLEVEL% EQU 0 (
SET internet=Connected to the internet.
) ELSE (
SET internet=Not connected to the internet.
)
echo %internet%
This works well because...
Reply from 10.11.1.106: Destination host
unreachable.
and since it has an errorlevel of zero this fails. (at least for me)ping -n 2
will still pass if there happens to be a dropped packet.