Use the start process and wait commands in PowerShell
I'm new to power shell. I don't have much programming background. I just try to use it for software packaging Anyway, I found the start - process command with the - wait parameter, which works for most things What I notice is that it waits not only for the process you specify, but also for any child process, even after the main process is no longer running Usually it's good, but I have a strange situation I am using start - process to run complex Oracle batch files The batch file finally runs setup Exe, this is what I really want to wait for, but other processes will also produce and never stop So if I use the - wait parameter, even setup Exe will no longer run and the script will not stop The closest thing I found was to use this:
saps -FilePath "Path\config.bat" -ArgumentList "arguments" Start-Sleep -s 10 Wait-Process -Name "setup"
This works, but I think there is a better way without using the timeout command Any ideas?
Solution
You can easily use this command:
$myprocss = start-process "powershell" -PassThru $myprocss.WaitForExit()
This command will continue when the process ends