23

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
  • Something very similar here
    – RBT
    Jul 13, 2017 at 10:16

1 Answer 1

37

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.

3
  • Works fine - and have you got any solution for finding application ?
    – hsz
    Oct 26, 2011 at 19:53
  • @hsz, updated my answer with a pointer to a similar question someone asked and the solution. I don't know of any quick hack for this, but if I find one, I'll add it. Oct 26, 2011 at 19:54
  • 1
    Invoke-Expression "$($complete_command_with_args) | Out-Null" worked for me.
    – EAmez
    Feb 5, 2019 at 15:07

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.