I am new to Powershell and don't have much of a programming background, just trying to use it for software packaging. Anyway, I found out about the start-process command with the -Wait parameter, and it works great for most things. What I noticed though is that not only does it wait for the process you specify, it waits for any sub processes, even after the main process is no longer running. Usually this is good, but I have a weird situation. I am running a complex Oracle batch file with start-process. The batch file eventually runs setup.exe which is what I really want to wait for, but other processes spawn too that never stop. So if I use the -wait parameter, the script never stops even after setup.exe is no longer running. The closest I've found is using this:
saps -FilePath "Path\config.bat" -ArgumentList "arguments"
Start-Sleep -s 10
Wait-Process -Name "setup"
This works, but I would think there'd be a better way without having to use a timeout command. Any ideas?
Using Start-Process
, there's an option for waiting:
Start-Process -Wait -FilePath "do_things.exe" -ArgumentList "argument another_argument"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With