run command in a loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 2
Joined: 06 Dec 2020 20:52

run command in a loop

#1 Post by dosW10 » 22 Sep 2021 01:02

I am having an executable called myExe. The command format to run it is : myExe X Y. X is from 0 to 5 and Y is from 0 to 3. To run these manually i need like 24 dos shell command windows for covering the entire parameter set. Each window run its own command. I need to monitor the 24 windows at the same time. Now, i have been trying to automate this with not much luck. I like a batch file that runs myExe within two loops with first loop iterates from 0 to 5 as first parameter and second one iterates from 0 to 3 as second parameter. Each time MyExe is called with its x and y setting, it creates a new window , returns immediately, with each window showing its own output. With sleep of 5 seconds between the next command. At the end I should end up with 24 shell windows seeing output lines in each. I was able to make it run once but was running sequentially which is NOT what I want.

Posts: 4289
Joined: 22 Jan 2010 18:01
Location: Germany

Re: run command in a loop

#2 Post by aGerman » 22 Sep 2021 02:16


Code: Select all

for /l %%X in (0 1 5) do (
  for /l %%Y in (0 1 3) do (
    start "result for %%X - %%Y" cmd /k myExe %%X %%Y
Not sure about the 5s delay you mentioned. If necessary add a >nul timeout /t 5 /nobreak into the inner loop.


Post Reply