How to run multiple DOS commands in parallel?

Batch FileCmd

Batch File Problem Overview


How to run multiple dos commands?

I have a for loop, which runs detection of server to detect which server works and is fast. And because there is more servers, I wish not to run all server detections in sequence, but in parallel.

Batch File Solutions


Solution 1 - Batch File

You can execute commands in parallel with start like this:

start "" ping myserver
start "" nslookup myserver
start "" morecommands

They will each start in their own command prompt and allow you to run multiple commands at the same time from one batch file.

Hope this helps!

Solution 2 - Batch File

I suggest you to see "How do I run a bat file in the background from another bat file?"

Also, good answer (of using start command) was given in "Parallel execution of shell processes" question page here;

But my recommendation is to use PowerShell. I believe it will perfectly suit your needs.

Solution 3 - Batch File

if you have multiple parameters use the syntax as below. I have a bat file with script as below:

start "dummyTitle" [/options] D:\path\ProgramName.exe Param1 Param2 Param3 
start "dummyTitle" [/options] D:\path\ProgramName.exe Param4 Param5 Param6 

This will open multiple consoles.

Solution 4 - Batch File

You can execute commands in parallel with start command, like:

start "" ping google.com

But to execute WITHOUT new window, use the /b option, like:

start /b ping google.com -t
start /b ping example.com -t

>Moreover, the -t option makes ping repeate infinite times.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohn BoeView Question on Stackoverflow
Solution 1 - Batch FileBali CView Answer on Stackoverflow
Solution 2 - Batch FileSergei DanielianView Answer on Stackoverflow
Solution 3 - Batch FileMohit KanojiaView Answer on Stackoverflow
Solution 4 - Batch FileTop-MasterView Answer on Stackoverflow