Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run an application with PowerShell and wait until it is finished

Tags:

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 !

like image 603
hsz Avatar asked Oct 26 '11 19:10

hsz


1 Answers

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.

like image 179
Michael Goldshteyn Avatar answered Oct 11 '22 22:10

Michael Goldshteyn