I got a problem with a batch-file.
Here it comes:
echo %time% pause for /L %%N IN (0, 1, 3) DO ( echo %time% pause ) echo 3. %time%
The first time in the loop is correct, but in the folowing all the times printed in the loop are the same, regardless how long you wait pressing the key. The last time is correct again. Somehow the %time% variable is not updated within the loop.
Try what I have put below. What exactly do you want it to output?
@echo off SetLocal EnableDelayedExpansion echo !time! pause for /L %%N IN (0, 1, 3) DO ( echo !time! pause ) echo 3. !time! EndLocal

讨论了批处理文件中使用循环时,时间变量未正确更新的问题,并提供了修复方法。
2287

被折叠的 条评论
为什么被折叠?



