How to Run Multiple Programs in a Sequence

How can I run multiple programs sequentially, from one solution?

Right click on your solution > Properties > Common Properties > Startup project

Select "Multiple startup Projects" and change the value of the Action column from "None" to "Start" or "Start without debugging"

How to run multiple programs using batch file

Basically, you could try this approach (not tested):

  1. Run the first program using the start command.

  2. Check the task list in a loop to see if the program has appeared there.

  3. Impose some time limitation to the said loop.

  4. Run the next program in case of success, exit with notification otherwise.

The scripting might look like this:

START program1.exe
FOR /L %%i IN (1,1,100) DO (
(TASKLIST | FIND /I "program.exe") && GOTO :startnext

:: you might add here some delaying
ECHO Timeout waiting for program1.exe to start

:: or START program2.exe

Keep in mind that the timing is not precise, especially if you are going to insert delays between the task list checks.

Run multiple programs sequentially in one Windows command prompt?

Since you're using Windows, you could just create a batch file listing each program you want to run which will all execute in a single console window. Since it's a batch script you can do things like put conditional statements in it as shown in the example.

import os
import subprocess
import textwrap

# create a batch file with some commands in it
batch_filename = 'commands.bat'
with open(batch_filename, "wt") as batchfile:
if errorlevel 1 (
@echo non-zero exit code: %errorlevel% - terminating
time /t
date /t

# execute the batch file as a separate process and echo its output
kwargs = dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
with subprocess.Popen(batch_filename, **kwargs).stdout as output:
for line in output:
print line,

try: os.remove(batch_filename) # clean up
except os.error: pass

open multiple programs sequentially with cmd

You will need one instance of cmd.exe for each sequence, in addition to the main instance. The operating system has no built-in support for sequencing processes, and cmd.exe doesn't support threading in command files.

You can do it like this:

 start "sequence1" cmd /c "First.exe & Second.exe & Third.exe"
start "sequence2" cmd /c "First.exe & Second.exe & Third.exe"
start "sequence3" cmd /c "First.exe & Second.exe & Third.exe"

The only way to avoid the (fairly modest) overhead of the extra instances of cmd.exe would be to write a solution in a real programming language rather than as a batch file.

You may also want to consider whether this is really want you want to do. Windows doesn't typically perform very well when hundreds of processes are running simultaneously.

How to execute a .bat to run multiple files in a timed sequence?

start "" "D:\scripts\script1.conf"
timeout /t 60 /nobreak > NUL
start "" "D:\scripts\script2.conf"
timeout /t 60 /nobreak > NUL

So this will run one file, wait for 60 seconds, and run the second.

start will open the file by its type-linked-program.

The first parameter "" specify the window title it started -- If the program can be titled.

You can incorporate these with for and goto to loop through some files or other conditions.

Related Topics

Leave a reply