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
If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
What does 0 |% 0 Do in batch? %0|%0 is a fork bomb. It will spawn another process using a pipe | which runs a copy of the same program asynchronously. This hogs the CPU and memory, slowing down the system to a near-halt (or even crash the system).
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With