0

I am trying to write a batch script that executes:

start /B /W %JmeterPath%\bin\jmeter.bat -n -t one.jmx -j one.log

and after completion of this execution, run these two commands in parallel:

start /B /W %JmeterPath%\bin\jmeter.bat -n -t two.jmx -j two.log
start /B /W %JmeterPath%\bin\jmeter.bat -n -t three.jmx -j three.log

I wrote the script as:

@echo off
SET JmeterPath=%1
echo "this is " %JmeterPath%
start /B /W %JmeterPath%\bin\jmeter.bat -n -t one.jmx -j one.log
PAUSE
start /B /W %JmeterPath%\bin\jmeter.bat -n -t two.jmx -j two.log
start /B /W %JmeterPath%\bin\jmeter.bat -n -t three.jmx -j three.log
PAUSE
Compo
  • 36,585
  • 5
  • 27
  • 39
venkat sai
  • 455
  • 9
  • 30
  • `command1 | command2` – Gerhard May 08 '19 at 10:18
  • 1
    With `Set "JmeterPath=%~1"`, I'd consider dropping the `Start` command from the first `.bat` line and replacing it with `Call "%JmeterPath%\bin\jmeter.bat"…`. Open up a Command Prompt window, enter `call /?`, to read the output usage information for the command. You should also enter `start /?` to discover what both the `/B` and `/W|/Wait` options do too. – Compo May 08 '19 at 10:31
  • 1
    As long as you instruct to `/W`ait for a command to complete, well, it will wait, of course; have you tried to remove the `/W` option? To wait for the parallelly executed commands check out [this answer](https://stackoverflow.com/a/33586872)... – aschipfl May 08 '19 at 10:57

1 Answers1

1

Here's one possibility

@Echo Off
Set "JmeterPath=%~1"
Rem Run batch file and then return
Call "%JmeterPath%\bin\jmeter.bat" -n -t one.jmx -j one.log
Pause
Rem Run batch files in parallel and return when both have completed.
(   Start Call "%JmeterPath%\bin\jmeter.bat" -n -t two.jmx -j two.log
    Start Call "%JmeterPath%\bin\jmeter.bat" -n -t three.jmx -j three.log
) | Set /P "="
Pause

[Edit /]: The same method for the parallel run is shown in the comment link by aschipfl.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • This solution is working but after completion of first command execution it is asking for user input to start the next two commands execution, can we fix that – venkat sai May 08 '19 at 12:41