Reputation: 149
I am trying to create a batch file which runs other batch files in a loop depending on a variable, however after the first batch file execution, the 'master' batch file also ends. What am i missing ?
:loop
if %variable% == 5 (bat1.bat) else (bat2.bat)
goto loop
Upvotes: 0
Views: 302
Reputation: 31221
It's because you are transferring control to the other batch file which means it never comes back to the 'master' one.
You need to use call
like this
:loop
if %variable% == 5 (call bat1.bat) else (call bat2.bat)
goto loop
Which will return control back to the master batch file after the one it calls has finished so it can continue the loop.
Hope this helps
Upvotes: 1