1

Say I have this batch file:

::Stuff

set counter=1
set amount=10

:BEGIN

::More stuff

set /a "counter+=1"
if %counter% LEQ %amount% goto BEGIN
::END

It is not continuing even when counter reach amount . What am I doing wrong? The reason I am not using a for loop is I need a variable to store the counter, and this would seem to be the easier route, not to mention FOR in batch is very weird compared to C-style methods of for().

Solved. If command corrected as follows:

if /i %counter% LEQ %amount% goto BEGIN
4

1 回答 1

3

你的代码对我有用。我不知道,你的批次是怎么回事:

@ECHO OFF &SETLOCAL
set counter=1
set amount=10

:BEGIN

ECHO %counter%

set /a "counter+=1"
IF %counter% LEQ %amount% goto BEGIN

添加/iIF没有影响。

于 2013-07-20T20:25:41.830 回答