Skip to content

Instantly share code, notes, and snippets.

@Dascr32
Created August 4, 2015 17:25
Show Gist options
  • Save Dascr32/9b7b0953ba0f33304e2c to your computer and use it in GitHub Desktop.
Save Dascr32/9b7b0953ba0f33304e2c to your computer and use it in GitHub Desktop.
Simple batch script that test your internet connection. It tells the number and time of disconnections. Also creates a log file in the c:/ drive with all the events.
@Echo off
title Connection Stability Test / Dascr32
cls
set /A disconnections=1
echo Start time:
time/t
echo ============================================ >> c:\cstb-log.txt
echo Connection Stability Test by Dascr32 Ver 1.2 >> c:\cstb-log.txt
echo. >> c:\cstb-log.txt
echo Start time: >> c:\cstb-log.txt
:: Write time and date to log file
time/t >> c:\cstb-log.txt
date/t >> c:\cstb-log.txt
echo. >> c:\cstb-log.txt
:pingServer
ping google.com
if errorlevel 1 (
echo.
echo ------------ No Connection ------------
time/t
echo.
set /A disconnections+=1
echo No. of disconnections: %disconnections%
:: Write to log file
echo Status: Disconnected >> c:\cstb-log.txt
time/t >> c:\cstb-log.txt
date/t >> c:\cstb-log.txt
echo No. of disconnections: %disconnections% >> c:\cstb-log.txt
echo. >> c:\cstb-log.txt
goto isStillDown
) else (
echo.
echo ------------ Connected ------------
time/t
)
:: Loop the test
goto pingServer
:isStillDown
ping google.com
if errorlevel 1 (
echo ------------ No Connection ------------
time/t
goto isStillDown
) else (
echo.
echo ------------ Back online ------------
time/t
:: Write to log file
echo Status: Back online >> c:\cstb-log.txt
time/t >> c:\cstb-log.txt
date/t >> c:\cstb-log.txt
echo. >> c:\cstb-log.txt
goto pingServer
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment