循环和%TIME%的批处理脚本

时间:2019-05-21 09:22:40

标签: batch-file

我试图编写一个来模拟一个ping请求的睡眠。

代码如下:

echo STARTED-^>  %DATE% -  %TIME%>> c:\Italprogetti\logfile.log
ping 127.0.0.1 -n 3 > nul
for /L %%x IN (1,1,10) do (
    echo EXECUTED-^>%%x  %DATE% -  %TIME% >> c:\Italprogetti\logfile.log
    ping 127.0.0.1 -n 3 > nul
)
echo ENDED-^>  %DATE% -  %TIME%>> c:\Italprogetti\logfile.log

问题是:为什么%TIME%在整个周期内都保持不变?

这是我的输出:

STARTED->  21/05/2019 -  11:17:25,36
EXECUTED->1  21/05/2019 -  11:17:27,38 
EXECUTED->2  21/05/2019 -  11:17:27,38 
EXECUTED->3  21/05/2019 -  11:17:27,38 
EXECUTED->4  21/05/2019 -  11:17:27,38 
EXECUTED->5  21/05/2019 -  11:17:27,38 
EXECUTED->6  21/05/2019 -  11:17:27,38 
EXECUTED->7  21/05/2019 -  11:17:27,38 
EXECUTED->8  21/05/2019 -  11:17:27,38 
EXECUTED->9  21/05/2019 -  11:17:27,38 
EXECUTED->10  21/05/2019 -  11:17:27,38 
ENDED->  21/05/2019 -  11:17:47,58

谢谢, 费德里科

0 个答案:

没有答案