"Counter" in Batch

This is a way to simulate the while loop you are trying to accomplish. Only one goto is needed:

@echo off
set /a x=0
:while
if %x% lss 5 (
  echo %x%
  pause>nul
  set /a x+=1
  goto :while
)
echo Test :D

You can do that with a simple FOR command :

for /l %%x in (0,1,100) do (
echo %%x
)

You can replace 100 by the number you want


To set a numerical value to a variable, you may use the /a switch:

The /A switch specifies that the string to the right of the equal sign is a numerical expression that is evaluated.

(Type SET /? for all the help).

Second, check your goto flow - this never loops back to A.

Third, check the syntax of the if expression (!= doesn't exist in batch).

Tags:

Batch File