
Utilities
Simple Internet Monitor for CMD
@echo off
setlocal EnableDelayedExpansion
:: Set log file location
set "LOGFILE=internet_log.txt"
set "TARGET=8.8.8.8" :: Google's DNS server - reliable target
set "INTERVAL=60" :: Seconds between checks (1 minute)
:: Check if log file exists, if not create it with header
if not exist "%LOGFILE%" (
echo Internet Monitoring Log > "%LOGFILE%"
echo Started: %date% %time% >> "%LOGFILE%"
echo ----------------------------------- >> "%LOGFILE%"
)
echo Internet Monitoring Started...
echo Logging to: %LOGFILE%
echo Press Ctrl+C to stop.
:monitor_loop
:: Get current timestamp
set "TIMESTAMP=%date% %time%"
:: Ping the target (1 attempt, timeout 2 seconds)
ping -n 1 -w 2000 %TARGET% | find "TTL=" >nul
if !errorlevel! equ 0 (
set "STATUS=ONLINE"
) else (
set "STATUS=OFFLINE"
)
:: Log the result
echo !TIMESTAMP! - Status: !STATUS! >> "%LOGFILE%"
echo !TIMESTAMP! - Status: !STATUS!
:: Wait for the specified interval
timeout /t %INTERVAL% /nobreak >nul
goto monitor_loop
:end
echo Monitoring stopped.
pause