On 29 Jun 2006 07:40:44 -0700,
(E-Mail Removed) wrote:
> (It is very difficult to search Google on this topic, because it
> ignores the % punctuation in my search. Very provoking.)
>
> As is well known, the %TIME% variable expands to the current time:
>
> C:\>echo %TIME%
> 10:36:30.71
>
> If I use it several times in a batch file that takes a nontrivial
> amount of time, the later times are indeed later:
>
>
> But in a loop, apparently %TIME% is only expanded once and then
> substituted the same on each loop pass:
>
>
> The other traditional way to get the time, using for with delims and
> TIME /T, doesn't get me the seconds, which I need. Any other way to
> get the current time while in a loop?
@echo off
setlocal EnableDelayedExpansion
for %%i in (1 2 3) do echo %%i !time! & ping -n 2 google.com >nul