新建txt文件,复制代码保存到新建文件后,修改文件后缀为.bat文件后。双击运行后会在本地脚本相同路径生成日志记录文件
@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 ) paus>nul
标签:文件,host%,windows,ping,echo,%%,本地,3% From: https://www.cnblogs.com/qingshuihexi/p/16809767.html