Windows connectivity check script

Wrote really simple¬†Windows CMD script that checks connectivity to any server or Internet. Change “google.com” to your application IP address or domain name.

@ECHO OFF

ECHO Checking connection to the application...
SET Connected=false
FOR /F "usebackq tokens=1" %%A IN (`PING google.com`) DO (
REM Check the current line for the indication of a successful connection.
IF /I "%%A"=="Reply" SET Connected=true
)

REM Check if a success was found.
IF "%Connected%"=="true" (
SET Internet=Application is working.
) ELSE (
SET Internet=Application is not working. Please contact #####.
)

ECHO %Internet%
pause

Server is reachable

Checking connection to the application…
Application is working.
Press any key to continue . . .

Server is down

Checking connection to the application…
Application is not working. Please contact #####.
Press any key to continue . . .

Leave a Reply

Your email address will not be published. Required fields are marked *