Windows批处理实现带时间戳ping

windows环境 ,

将以下代码保存为 .bat文件

复制代码
@echo off
@echo.----------------------------------------------------------
@echo.-----------------------------------------------------------
@echo off
set /p host=please input your destination ip  :  
set logfile=Log_%host%.log
echo Target Host = %host% >%logfile%
for /f "tokens=*" %%A in ('ping %host% -n 1 ') do (echo %%A>>%logfile% && GOTO Ping)
:Ping
for /f "tokens=* skip=2" %%A in ('ping %host% -n 1 ') do (
    echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A>>%logfile%
    echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A
    timeout 1 >NUL 
    GOTO Ping)

双击后,即开始执行长ping,会将输出写入到当前目录下的log_IP文件中。

如下图

相关推荐
2501_925435521 天前
怎么彻底禁止Windows更新?一键彻底关闭win11自动更新的工具
windows
dust_and_stars1 天前
ubuntu24使用apt安装VS-code-server code-server
linux·服务器·windows
郑泰科技1 天前
快速地图匹配(FMM)在轨迹可视化中的核心应用
windows·python·交通物流
梦星辰.1 天前
超大 JSONL 数据集交互式查看器 Linux便捷工具
linux·windows·microsoft
取个名字太难了a1 天前
插入APC
windows
非凡ghost1 天前
ImageConverter(图像转换编辑工具)
图像处理·人工智能·windows·学习·计算机视觉·软件需求
洛克大航海1 天前
Python 在系统 Windows 和 Ubuntu 中创建虚拟环境
windows·python·ubuntu·虚拟环境
ZEERO~1 天前
@dataclass的作用
开发语言·windows·python
雪域迷影1 天前
Windows11上安装Redis服务和Redis可视化客户端
windows·redis
广然1 天前
Windows 11 关闭 VBS 的几种方法
windows·ensp·vbs