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.
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.
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.
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.
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 repeat infinite times.Also, try Ctrl + Break if Ctrl + C does not work (but
Ctrl+C
works for above example).
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.