簡體   English   中英

Powershell 是否可以並行啟動進程-等待

[英]Powershell Is it possible to start process -wait in parallel

我嘗試過這樣的事情,它一個接一個地開始

  function start-parallel {  
    workflow work {
      start-process $exe1 -wait
      start-process $exe2 -wait
    }

    work 
  }

不,你不能同時waitnot wait

您要做的是通過Start-Process -PassThru將進程對象 output 保存到變量中,然后不要等到啟動所有進程之后

$processes = @(
  Start-Process $exe1 -PassThru
  Start-Process $exe2 -PassThru
  # ...
)

# now wait for all of them
$null = $processes |ForEach-Object WaitForExit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM