Powershell: start multiple processes and put them in a list and observe them

68 views Asked by At

i want to create some Powershellscript where i can add a uncertain number of processes to a list. After that i want to observe, if the processes are finished.

so i created this:

$procs = New-Object -TypeName 'System.Collections.ArrayList';

$procs += Start-Process Notepad.exe -PassThru
$procs += Start-Process Calc.exe -PassThru

Write-Host Processes started

$procs | Wait-Process

Write-Host Processes endet

My issue is when i close notepad and not the calculator it tells me that the processes have ended.

Can tell me sombebody why this reacts like this or is there a cleaner solution?

0

There are 0 answers