LATEST ADDITIONS:



 

Windows batch loop help?

Home > Computers & Internet > Programming & Design > Windows batch loop help?
Bert HinkleBert Hinkle


I need 2 loop something a limited amount of times like if my code was

@echo off

echo i like cheese

how would i make it say i like cheese 100 times then quit saying it

Ratchetr
Ratchetr

@echo off

set n=1

:loop

if %n% GTR 100 goto endloop

echo i like cheese %n%

set /a n=n+1

goto loop

:endloop

Or, this version is a bit shorter. (It's a DO WHILE loop rather than a WHILE loop):

@echo off

set n=1

:loop

echo i like cheese %n%

set /a n=n+1

if %n% LEQ 100 goto loop

Run Help if to see all the operators like GTR and LEQ that are supported.


Other Questions & Answers

What is the best way to watch NBA games online live with good quality ?
What is the best way to watch NBA games online live with good quality ? ... Read more (3 answers)
How do i use my current IP in another country?
Okay so i will be traveling to Germany and would like to watch british tv online over there, since the BBC iplayer only allows British IP'S to wa ... Read more (8 answers)
Lavasoft total security vs kaspersky internet security 2011?
Based on tests/evidence..tell me which one is better. Because I just posted a question between AVG IS 2011 AND bitdefender is 2011 and avg won, now te ... Read more (1 answers)
Anyone else having trouble with microsoft and windows update today ?
I know how to fix alot of stuff on the computer ...but this one has me baffled....I click on Microsoft updates...and see if I have any updates to load ... Read more (1 answers)
Why doesn't Adobe Flash work on IE 9 in Win7/32 bit?
A brand new OS installation - no productivity software just Win7, the recommended updates and iTunes.There are no other browsers installed. ... Read more (2 answers)