Computing.Net > Forums > Programming > Batch: %time% won't update in loop

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: %time% won't update in loop

Reply to Message Icon

Name: do1eh
Date: July 21, 2008 at 05:31:46 Pacific
OS: WinXP
CPU/Ram: 1GB
Product: HP
Comment:

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.

Any ideas?



Sponsored Link
Ads by Google

Response Number 1
Name: Pagey
Date: July 21, 2008 at 05:40:44 Pacific
Reply:

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


1

Response Number 2
Name: do1eh
Date: July 22, 2008 at 01:40:25 Pacific
Reply:

thanks that solved it


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch: %time% won't update in loop

batch file to change prices in ini www.computing.net/answers/programming/batch-file-to-change-prices-in-ini/17482.html

VB6 working model won't install in XP? www.computing.net/answers/programming/vb6-working-model-wont-install-in-xp/3030.html

PPC: New Line character won't work www.computing.net/answers/programming/ppc-new-line-character-wont-work/14131.html