在 PowerShell 中等待进程退出 [英] Waiting for an process to quit in PowerShell

查看:68
本文介绍了在 PowerShell 中等待进程退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在不需要运行的情况下等待进程退出?我知道有关键字 WaitForExit,但要使用它,进程需要运行.

Is there a possibility to wait for an process to quit, without it needs to running? I know there is the keyword WaitForExit, but to use this the process needs to run.

我的第二个问题是,是否有可能在 while 循环中使用 else 语句.已经试过了,但总是说没有调用else的函数.

My second question is, if there is a possibility to use an else-Statement in an while loop. Tried it already, but it always said that there isnt an function called else.

推荐答案

Do直到

Do {
    Sleep 5
} Until (Get-Process iexplore);

会等到找到 iexplore

Will wait until iexplore is found

While (Get-Process iexplore) {
    Sleep 5
}

将等到 iexplore 不再运行

Will wait until iexplore is no longer running

不能在 while 循环后使用 else 语句.

You cannot use an else statement after a while loop.

它需要在 if 之后.

这篇关于在 PowerShell 中等待进程退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆