并行运行第一个命令以完成命令和后续命令

时间:2019-05-08 09:36:54

标签: batch-file jmeter

我正在尝试编写一个可执行的批处理脚本:

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

此执行完成后,并行运行以下两个命令:

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

我将脚本编写为:

@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

1 个答案:

答案 0 :(得分:1)

这是一种可能性

@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

[编辑/]:aschipfl的注释链接中显示了用于并行运行的相同方法。