$exitCode = [Diagnostics.Process]::Start(<process>,<arguments>).WaitForExit(<timeout>)
Wait-Process [[-Timeout] <Int32>] [-Any] [-PassThru] -InputObject <Process[]> [<CommonParameters>]说明此cmdlet 在 Linux 或 macOS 上不起作用。 Wait-Process cmdlet 等待一个或多个正在运行的进程在接受输入之前停止。 在 PowerShell 控制台中,此 cmdlet 将禁止命令提示符,直到进程停止。 可以按进...
此Cmdlet 使用System.Diagnostics.Process類別的WaitForExit方法。 與Start-Process -Wait不同,Wait-Process只會等候所識別的進程。Start-Process -Wait等候進程樹狀結構(進程及其所有子系)在傳回控件之前結束。 相關連結 本文內容 語法 Description 範例 參數
$firstProcess = Start-Process "myprogramA.exe" -PassThru $firstProcess.WaitForExit() Start-Process "myprogramB.exe" 继续探讨 Start-Process 的应用: 81. 通过命令行执行 SQL 脚本 可以启动 SQL 命令行工具并执行脚本: powershellCopy Code Start-Process "sqlcmd.exe" -ArgumentList "-S server -d dat...
在运行next命令之前,等待其他会话中的多个同时执行的powershell命令完成您确实在寻找Powershellbackground ...
问当我的进程通过“停止进程”或任务管理器被“杀死”时,如何运行PowerShell函数?EN在一次系统迭代后...
因此,无论外部程序做什么,当它退出时总会产生一行 FOO,因此管道将立即停止(然后 FilterOutFooString 只负责产生实际输出)。这不是特别“好”,并且有额外的开销,因为一切都需要通过 cmd 进行管道传输(或者我认为任何其他 shell 也可以工作)。我希望 管道链运算符 本身允许这样做,但他们似乎不允许:尝试相同的语法会...
我已经编写了一个执行.exe文件的脚本--这个exe运行时大约是3个小时,但在2小时后就会不断崩溃(大约1-...
How to Set-Timeout for the Cmdlet "Get-Service" How to solve the "Method invocation failed" error in script? How to spawn a command prompt and run an application with powershell How to specify a case-insensitive search using PowerShell's "Criteria Expression Syntax" & the MATCHES operator...
Concerning the above solution, the Start() method started the given process we passed as an argument while WaitForExit()waited for this process to end. Further reading: Press Any Key to Continue in PowerShell Read more → How to Run ps1 File from PowerShell Read more → Using Out-...