@echo off set /p host=host: set logfile=ping_%host%.log echo Target Host=%host% > %logfile% :loop for /f "tokens=* skip=2" %%A in ('ping %host% -n 1') do ( echo %date:~0,-3% %time:~0,-3% %%A>>%logfile% echo %date:~0,-3% %time:~0,-3% %%A timeout /t 1 /nobreak>nul goto loop ) pause>nul
将代码保存为bat文件,运行之后输入需要ping的ip地址或者网址即可。