What you need is delayed variable expansion:
FOR /l %%x IN (1,1,10) DO (
AutomatedTest.exe cip.log
ECHO !ERRORLEVEL!
)
To enable delayed variable expansion precede your batch with SETLOCAL ENABLEDELAYEDEXPANSION
or start command shell with CMD.EXE /V:ON
.
Another approach is using subroutines:
FOR /l %%x IN (1,1,10) DO CALL :Test
GOTO :EOF
:Test
AutomatedTest.exe cip.log
ECHO %ERRORLEVEL%
GOTO :EOF
Yet another approach is to use IF ERRORLEVEL
.