Using a batch file would it be possible to do something like:
ping google.com
if return success do ECHO You are connected to the internet
else return ECHO You are not connected to the internet
You can use following snippet:
@echo off
Ping www.google.de -n 1 -w 1000
if errorlevel 1 echo Not connected
Here's a script that will repeatedly check, and write the time (from system clock) and "internet offline" to a log file at C:\Internet.txt each time the internet goes offline. Unfortunately the latest line in the log file will appear at the end - I don't know how to make it appear at the top ;)
BTW: I set the wait time (-w) to 20 seconds, because I was using a 3G dongle (with 2G internet) so 20s was often the only way to be sure if the internet was really down or something else was the problem... Feel free to change it to 5000 for 5s, or delete "-w 20000" altogether to leave it at default.
@echo off
:START
ping -n 4 4.2.2.2 -w 20000 >nul
if %errorlevel% == 1 (
echo Internet offline >> C:\Internet.txt
Time /t >> C:\Internet.txt
)
Timeout /t 30
@set errorlevel = 0
GOTO START
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With