title: Using start-process and -wait command in Powershell
body: <p>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:</p>
  
  <pre><code>saps -FilePath "Path\config.bat" -ArgumentList "arguments"
  Start-Sleep -s 10
  Wait-Process -Name "setup"
  </code></pre>
  
  <p>This works, but I would think there'd be a better way without having to use a timeout command.  Any ideas?</p>