wait command in Powershell

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 "Pathconfig.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?


you can use this command easy :

$myprocss = Start-Process "powershell" -PassThru 
$myprocss.WaitForExit()

this command will continue when process end .

链接地址: http://www.djcxy.com/p/89662.html

上一篇: 以当前登录的用户身份运行powershell命令

下一篇: 在Powershell中等待命令