0

I tried something like this and it starts one after the other

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

    work 
  }
mklement0
  • 382,024
  • 64
  • 607
  • 775
user310291
  • 36,946
  • 82
  • 271
  • 487
  • 1
    Does this answer your question? [Can Powershell Run Commands in Parallel?](https://stackoverflow.com/questions/4016451/can-powershell-run-commands-in-parallel) – Nick.Mc Aug 15 '22 at 21:25
  • no because problem is start-process -wait – user310291 Aug 16 '22 at 07:49
  • 1
    The linked script uses `Start-Job` not `start-process`. Unless I missed something – Nick.Mc Aug 16 '22 at 07:52
  • @Nick.McDermaid ah I don't know anything about Start-Job thanks will look again. – user310291 Aug 16 '22 at 18:12
  • Note that Windows PowerShell Workflows were introduced in v3, but never really took off. Given that they're [no longer available in PowerShell (Core) v6+](https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/), where all future development effort will go, I think it's fair to call it an obsolescent technology. – mklement0 Aug 16 '22 at 23:14

1 Answers1

1

No, you can't simultaneously wait and not wait.

What you'll want to do is save the process objects output by Start-Process -PassThru to a variable, and then not wait until after you've kicked off all the processes:

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

# now wait for all of them
$null = $processes |ForEach-Object WaitForExit
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206