batch-file

Non-blocking batch file execution


I have the following commands in a batch file:

"C:\MI2\Stream\bin\Debug\Stream.exe" 19
"C:\MI2\Stream\bin\Debug\Stream.exe" 20
"C:\MI2\Stream\bin\Debug\Stream.exe" 21
"C:\MI2\Stream\bin\Debug\Stream.exe" 23
"C:\MI2\Stream\bin\Debug\Stream.exe" 25

I'm attempting to execute 5 instances of an application I created, passing in a different param to each. My goal is that when I run this batch file, it launches the 5 instances of this app, loading a UI component for each. Eventually I will make this more elegant, and put a wrapper app around this, but for now i just want these to run simultaneously.

The problem is, when I launch this batch file, it executes the first line, loading the UI. That's it. It doesn't move on to the second line. Thoughts?

Edit to Add - I could certainly do this from separate batch files, but I'd like to have one-click launching. Scott


Solution

  • You can use start:

    start "" "C:\MI2\Stream\bin\Debug\Stream.exe" 19
    start "" "C:\MI2\Stream\bin\Debug\Stream.exe" 20
    start "" "C:\MI2\Stream\bin\Debug\Stream.exe" 21
    start "" "C:\MI2\Stream\bin\Debug\Stream.exe" 23
    start "" "C:\MI2\Stream\bin\Debug\Stream.exe" 25
    

    The first argument is the title of the created command line window, which we don't care about, so it can be left empty.

    Even better would be to use for:

    forr %i in (19, 20, 21, 23, 25) do start "" "C:\MI2\Stream\bin\Debug\Stream.exe" %i