@ECHO OFF SETLOCAL EnableDelayedExpansion FOR /F "tokens=1,2 delims=#" %%a IN ('"PROMPT #$H#$E# & echo on & for %%b in (1) do rem"') do ( SET "DEL=%%a" ) for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a" REM Start :start REM SET Target SET /p hostInput=" - Target (Enter your IP or URL): " If "%hostInput%"=="" ECHO.&GOTO start REM SET loops SET /p loopsInput=" - Requests number: " SET /a loops=loopsInput REM SET time limit SET /p maxmsInput=" - Maximum Time Limit (ms): " SET /a maxms=maxmsInput REM Value used for sleep between loops SET /p sleepInput=" - Delay between requests (s): " SET /a sleepDelay=sleepInput+1 REM Variables SET displayText="" SET /a countRequestsOk=0 SET /a countRequestsKo=0 SET /a totalRequests=0 SET /a maxTime=0 ECHO. ECHO START at %TIME% [Pinging %hostInput%, requests: %loops%, time limit: %maxms% ms, delay: %sleepInput% s] ECHO. REM Loop :loop REM Set time FOR /f "tokens=1-3 delims=/:" %%a IN ("%TIME%") DO (SET mytime=%%ah%%bm%%cs) REM Get ping value FOR /f "tokens=3delims==" %%a IN ('PING -n 1 %hostInput%') DO FOR /f "delims=m" %%b IN ("%%a") DO ( SET /a timems=%%b SET /a totalRequests+=1 REM Check result IF !timems! GTR %maxms% ( GOTO failed ) ELSE ( GOTO success ) ) REM Request success :success SET /a countRequestsOk+=1 SET displayText="Reply from %hostInput% - !timems!ms" CALL :ColorText 02 !displayText! GOTO next REM Request failed :failed IF !countRequestsOk! GTR 0 ECHO. SET /a countRequestsOk=0 SET /a countRequestsKo+=1 SET displayText="Reply from %hostInput% - !timems!ms" CALL :ColorText 0c !displayText! GOTO next REM Next loop :next REM Sleep a little bit IF %sleepDelay% GTR 1 ( ping -n %sleepDelay% localhost > nul ) REM Check continue SET /a loops-=1 IF %loops% gtr 0 GOTO loop REM Display result IF !countRequestsOk! GTR 0 ECHO. ECHO. ECHO STOP at %TIME% ECHO. if !countRequestsKo! GTR 0 ( SET displayText="!countRequestsKo! requests over %maxms% ms on !totalRequests! requests in total" CALL :ColorText 0c !displayText! ) ELSE ( SET displayText="No request over %maxms% ms on !totalRequests! requests in total" CALL :ColorText 02 !displayText! ) REM Ask if restart ECHO.&ECHO ********************* SET /p restartInput="Do it again ? (Y/N): " If "%restartInput%"=="" ECHO *********************&GOTO start If /I "%restartInput%"=="y" ECHO *********************&GOTO start If /I "%restartInput%"=="n" ECHO *********************&GOTO end REM End :end PAUSE GOTO :EOF REM Line color :ColorText ECHO off ECHO %DEL% > "%~2" FINDSTR /v /a:%1 /R "^$" "%~2" NUL DEL "%~2" > NUL 2>&1