我首先要说我对脚本很陌生...
我正在尝试创建一个定期 ping 主机的批处理文件。目前,我只是在我的本地 PC 上测试它。这是我到目前为止所得到的:
@echo off
set SERVERNAME=127.0.0.1
set limit=3
ECHO %date%, %time% Starting ping test to localhost>>c:\users\%username%\desktop\Pingtest.txt
for /l %%X in (1,1,%limit%) do (
ping %servername% -n 3 | FIND "Reply" >>c:\users\%username%\desktop\Pingtest.txt
echo %time% >>c:\users\%username%\desktop\Pingtest.txt
Timeout /t 5
)
Exit
Run Code Online (Sandbox Code Playgroud)
但是,时间戳始终保持不变。它应该将时间显示为大约 5 秒后(或设置超时值的时间),但与第一个时间戳保持相同。下面是一个输出示例:
25/08/2015, 2:09:18.34 Starting ping test to localhost
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
2:09:18.34
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from …Run Code Online (Sandbox Code Playgroud) batch-file ×1