@echo off REM ------------------------------------------------------------------- REM - lazyping.cmd - Written by: Chris Kantack Date: 5/17/2022 - REM ------------------------------------------------------------------- SET logfile="C:\Temp\default.txt" echo: SET /p targ="Enter target IP address or destination name: " echo: SET /p numb="Enter number of pings to send: " echo: SET /p secs="Enter number of seconds to wait between pings: " echo: SET /p logsw="Do you wish to output to a logfile? (Y/N): " if /i "%logsw%"=="Y" ( SET /p logfile="Enter log file pathname: " GOTO PROCEED ) if /i "%logsw%"=="N" ( GOTO PROCEED ) echo: echo '*** Invalid Response *** - please rerun script with Y or N input' echo: GOTO END :PROCEED if /i "%logsw%"=="Y" ( del /F %logfile% 2>nul ) setlocal enabledelayedexpansion FOR /L %%c IN (1, 1, %numb%) DO ( SET nomtime=!time:~0,8! SET datetime=!date! !nomtime! if /i "%logsw%"=="Y" ( echo !datetime! 1>>%logfile% ping -n 1 %targ% | FIND "time=" 1>>%logfile% ) if /i "%logsw%"=="N" ( echo: echo !datetime! ping -n 1 %targ% | FIND "time=" ) timeout /T %secs% 1>nul ) endlocal enabledelayexpansion :END echo: