Run an application with PowerShell and wait until it is finished

冷暖自知 提交于 2019-12-18 14:08:24

问题


Is it possible to run an application with PowerShell and wait until it is finished ? For example I want to run Thunderbird and after user closes it, then print something to the output ?

Second thing - is it possible to search for this application using thunderbird keyword like in Start Menu (when we type it manually, it returns a result Mozilla Thunderbird) - and also run it ?

Thanks !


回答1:


You can do something like:

Start-Process myprogram.exe -NoNewWindow -Wait

Or if you would like a more concise mechanism, there's always the Out-Null hack:

myprogram.exe | Out-Null

Piping will wait for the program to terminate, and hence we pipe to Out-Null

As for finding an app, this SO question covers how to do this. Here is another article demonstrating this method.

You might also want to look at this article on how to make Powershell interact with Windows Search and this one, which is what the Start Button uses.



来源:https://stackoverflow.com/questions/7908000/run-an-application-with-powershell-and-wait-until-it-is-finished

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!