Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run multiple DOS commands in parallel?

Tags:

batch-file

cmd

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.

like image 781
John Boe Avatar asked Jun 13 '12 08:06

John Boe


People also ask

Can you run 2 command prompts at once?

Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.


2 Answers

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!

like image 54
Bali C Avatar answered Sep 19 '22 08:09

Bali C


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.

like image 40
Sergei Danielian Avatar answered Sep 17 '22 08:09

Sergei Danielian