Windows批处理:在后台运行一个进程,等待它 [英] Windows batch: run a process in background and wait for it
本文介绍了Windows批处理:在后台运行一个进程,等待它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从我的批处理作业启动2后台进程,然后等待他们。 Unix外壳类似物是:
I need to start 2 background processes from my batch job and then wait for them. Unix shell analogue is:
myprocess1 -flags1 &
pid1=$!
myprocess2 -flags2 &
pid2=$!
wait ${pid1}
wait ${pid2}
任何想法?
推荐答案
您可以解决它,使用一个开始包装。
You could solve it, using a start wrapper.
该包装始于进程启动/等待
和后工序完成它删除信令的文件。
The wrapper starts a process with start /wait
and after the process is finished it deletes a file for signaling.
您通过包装开始的第一个过程,你可以用开始第二次启动/等待
。结果
那么你只需要等待该文件。
The first process you start through the wrapper, the second you can start with start /wait
.
Then you only need to wait for the file.
Echo > waiting.tmp
Start cmd /c wrapper.bat myprocess1 -flags1
start /wait myprocess2 -flags2
:loop
if exist waiting.tmp goto :loop
wrapper.bat含量
content of wrapper.bat
start /wait %*
del waiting.tmp
这篇关于Windows批处理:在后台运行一个进程,等待它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文