Created
January 17, 2022 23:19
-
-
Save GJivan/cd523fa071c9500323bdc67455c8bc27 to your computer and use it in GitHub Desktop.
Ping Bat Script with TimeStamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
Rem ######## Replace Log File Location ########## | |
set logfile=logFile1.txt | |
echo. | |
set /p IP="Enter IP Address to ping: " | |
echo. | |
echo. | |
set /p INTERVAL="Enter time (in seconds) to wait between pings: " | |
echo. | |
echo. | |
set /p PINGCOUNT="Enter # of pings per requests: " | |
echo. | |
echo +-----------------------------------------------------------------+ | |
echo + Press any key to initiate additional pings before timer expires + | |
echo +-----------------------------------------------------------------+ | |
echo. | |
echo %date% %time% IP: %IP% >> %logfile% | |
:Ping | |
for /f "tokens=* skip=2" %%A in ('ping %IP% -n %PINGCOUNT% ') do ( | |
echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A | FIND "Reply" >>%logfile% | |
Rem ######### Uncomment to see output########## | |
Rem echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A | |
) | |
timeout %INTERVAL% | |
GOTO Ping |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment