Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PowerShell to wait for Invoke-Item completion?

How do I get PowerShell to wait until the Invoke-Item call has finished? I'm invoking a non-executable item, so I need to use Invoke-Item to open it.

like image 488
arathorn Avatar asked Apr 23 '10 17:04

arathorn


People also ask

Does PowerShell wait for command to finish?

In addition, Windows PowerShell does not wait for the commands to finish when running executable programs. This article will show you ways to force the Windows PowerShell environment to wait for the commands with executable files to finish before moving to the following command.

When would you use the wait job command?

The Wait-Job command determines whether all of the commands have completed within 30 seconds. It uses the Timeout parameter with a value of 30 to establish the maximum wait time, and then stores the results of the command in the $done variable.

What is IEX command in PowerShell?

iex is an alias for Invoke-Expression . Here the two backticks don't make any difference, but just obfuscates the command a little. iex executes a string as an expression, even from pipe. Here Start-Process is a cmdlet that starts processes.

What does invoke-expression do in PowerShell?

Description. The Invoke-Expression cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command. Without Invoke-Expression , a string submitted at the command line is returned (echoed) unchanged. Expressions are evaluated and run in the current scope.


1 Answers

Just use Start-Process -wait, for example Start-Process -wait c:\image.jpg. That should work in the same way as the one by @JaredPar.

like image 129
stej Avatar answered Oct 07 '22 22:10

stej