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):
Run the first program using the
start
command.Check the task list in a loop to see if the program has appeared there.
Impose some time limitation to the said loop.
Run the next program in case of success, exit with notification otherwise.
The scripting might look like this:
@ECHO OFF
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
GOTO :EOF
:startnext
program2.exe
:: 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:
batchfile.write(textwrap.dedent("""
python hello.py
if errorlevel 1 (
@echo non-zero exit code: %errorlevel% - terminating
exit
)
time /t
date /t
"""))
# execute the batch file as a separate process and echo its output
kwargs = dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
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
Why Does Script Not Recognize File Extension
Command Substitution Doesn't Work in Script Text Passed Over Ssh
Bash -C Variable Does Not Get Assigned
How to Read from Text File Line-By-Line and Split the Line by a Character
Split File into Multiple File Using Awk, But in Date Format
Print Differences of File1 to File2 Without Deleting Anything from File2
Using Ssh to Run a Cleartool Command with Agruments on Remote a Linux MAChine
Bash Script to Remove Directories Based on Modified File Date
Phusion Passenger Nginx Module Installer V3.0.17 Issue on Debian 6.0.5 Amd64 Due to Broken Package
Bash/Linux Sort by 3Rd Column Using Custom Field Seperator
How to Execute 4 Shell Scripts in Parallel, I Can't Use Gnu Parallel
Update Specific Field in Text File in Specific Line
Compute Base64 Encoded Hash from a Given Hash
What Is an Absolute Pathname VS a Relative Pathname
How to Route Webcam Video to Virtual Video Device on Linux (Via Opencv)
Why Count Differs Between Ls and Ls -L Linux Command