Skip to content

Instantly share code, notes, and snippets.

@Techlogist
Last active October 3, 2021 12:36
Show Gist options
  • Save Techlogist/d2159d24e908d3e3698523dc3e2ed40e to your computer and use it in GitHub Desktop.
Save Techlogist/d2159d24e908d3e3698523dc3e2ed40e to your computer and use it in GitHub Desktop.
Check Internet connection status
REM License: GNU General Public License v2.0
REM Author: Miguel
REM Website: www.techlogist.net
REM Post: https://techlogist.net/batch/check-internet-connection-status
REM Description: The script allows the test and troubleshooting of the internet connection over IPv4
REM OS/Language/Region: Windows/EN-US
@echo off
REM This script tests the connection over IPV4
title INTERNET CONNECTION TEST
color f0
mode con:cols=70 lines=15
:start
set pings_count=20
set /A pings_count_2=%pings_count%/2
echo.
echo.
echo Testing your connection…
echo.
FOR /f "tokens=4 delims=(=" %%G IN ('ping -4 -n %pings_count% google.com ^|find "loss"') DO set connect=%%G
goto step0
:step0
cls
echo.
echo Current interface Status:
echo.
netsh interface show interface
echo.
echo.
if /I %connect%==%pings_count% (echo There is no connection! && goto troubleshoot) ELSE (goto step2)
:step2
if /I %connect%==%pings_count_2% (echo There are connection issues! && goto troubleshoot) ELSE (goto step3)
:step3
if /I %connect%==0 (echo The connection is OK! && goto exit)
:troubleshoot
pause>nul
echo.
echo To troubleshoot and test again press any key…
pause>nul
cls
echo.
echo.
echo Troubleshooting…
ipconfig /release>nul
ipconfig /flushdns>nul
ipconfig /renew>nul
goto start
:exit
pause>nul
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment