功能:一直ping一个IP地址,然后将带时间的结果输出到文件中
将如下内容保存在文件中,以.bat作为结尾。如1.bat。
@echo off
set filePath=C:\Users\2533536\Desktop\1.txt # 保存的文件路径
set ping_url=10.136.251.214 # 要ping的IP地址
set sleep_times=5
:top
echo starting test network...
echo %date% %time%>>%filePath%
ping %ping_url% -n 1|findStr "TTL" >> %filePath%
ping -n %sleep_times% 127.1 >nul
goto top
效果截图: