I want to execute same exe with different, parallel arguments each time in a loop.
So I decided to use Start-Job
, but when I try it, I realize that when the second instance starts, the first is cancelled:
foreach($name in $insanceNames)
{
Start-Job -ScriptBlock { & "C:\program.exe" $args } -ArgumentList /instName,$name
}
When second instance is started, the first one is interrupted with no errors.
If I execute the same program, in parallel, through two consoles manually, I don't have this problem.
NOTE: I cannot start program just with "&" because I need to run them without waiting previous instance finishes.
Finally I changed Start-Job
for Start-Process
and it works as I expected.
I was looking for the difference between both in this post and i don't understand why Start-Job
stops previous instance and Start-Process
keep all the intance as expected.
However, I solved my problem.