Wednesday, October 31, 2012

Default Gateway Ping Test Batch File

This is a batch file that will let you test your connection status by pinging your default gateway.  Copy this code into notepad and save the file with a .BAT or .CMD extension.

@ECHO OFF
COLOR 1F
TITLE GATEWAY PING TEST
:PINGTEST
CLS
FOR /F "TOKENS=2 DELIMS=:" %%G IN ('IPCONFIG ^| find "Default Gateway"') DO (
    IF NOT "%%G"==" " (
        PING -w 30000 -n 1 %%G
        IF ERRORLEVEL 1 ECHO UNABLE TO PING GATEWAY!!!
    )
)
ECHO.
CHOICE /T 5 /D Y /M "WAITING 5 SECONDS BEFORE RETRY"
GOTO PINGTEST

*This has only been tested with Windows 7.  YMMV

No comments:

Post a Comment