I am trying to call same batch file X times (in this code its 3) while passing a variable that is from a list that I cycle through. So in this case the list is (I J M) so I wish to call the batch file X times passing I then J then M then I then J then M and so on.
My current code is this:
@echo off
set letters=I J M
set /a dl = 0
setlocal enabledelayedexpansion
for %%i in (%letters%) do (
set /a dl+=1
set ltrs[!dl!]=%%i
)
set /a lCount = 0
for /l %%x in (1, 1, 3) do (
start "RBatch%%x" cmd /k call RBatch.bat !ltrs[!lCount!]!
set /a lCount+=1
if !lCount! geq !dl! set /a lCount = 0
)
PAUSE
The RBatch.bat file is just:
echo %1
PAUSE
Currently RBatch.bat just displays lCount...
What am I doing wrong?
Thanks