Variables with percentages are expanded before the statement / block is executed.
Thus, in your case, the complete block expands to execution echo %ITER%, to a constant echo 0.
The ITER variable itself is updated correctly in the loop.
To avoid this, you can use slow expansion, it works as a percentage extension, but only at runtime
@echo off
setlocal EnableDelayedExpansion
SET ITER=0
for %%i in (%*) do (
SET /a ITER+=1
ECHO !ITER!
)
source
share