2

I am running Windows 10, using a batch file to run multiple processes as shown below. Each command solves a finite element analysis model that takes an unpredictable amount of time typically in the range of 1 to 5 hours. My computer is capable of running two analyses simultaneously, so I use the start command in every other command.

start programName param1
programName param2
start programName param3
programName param4
etc...

My problem is that the third command doesn't start until both the first and second commands are finished. I prefer that there would be two commands running at all times.

I have considered running two batch files simultaneously instead as shown below, but then one batch file might finish while the other still has multiple commands waiting to run.

[batch1.bat]
programName param1
programName param2
etc...

[batch2.bat]
programName param3
programName param4
etc...

Is there an easy existing method to ensure that there are always exactly two commands running in parallel? If not, I will probably work on hacking something together in c++ using the system command.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
James
  • 121
  • 2
  • 1
    Perhaps try to get the number of running `programName` processes using `tasklist` and start next one as soon as there are less than two processes found... – aschipfl Aug 11 '16 at 15:07
  • 2
    I recommend the [2nd answer to the duplicate question](http://stackoverflow.com/a/11715437/1012053). You can easily modify it to specify the max number of parallel processes, and you should be able to modify the source of the jobs without much trouble. – dbenham Aug 11 '16 at 23:13

0 Answers0