Reputation: 845
I am trying to install an exe created using Inno Setup. When I try to install it using PowerShell with
Start-Process -wait C:\updatefile.exe /VERYSILENT
all folders are created at proper places, registry values are created, but console hangs and does not return unless Ctrl+C is pressed.
But if I install exe using command prompt with
start /wait C:\updatefile.exe /VERYSILENT
everything goes properly and command prompt returns.
What could be cause of this anomaly?
I need this exe to install through Dockerfile, but as PowerShell install is hanging, container does not install exe. Even with cmd
version in Dockerfile, container does not create install folders.
After checking logs I found that exe service is being started by installer in end. If that is reason for hanging, is there some argument I can use to exit PowerShell?
Upvotes: 3
Views: 3914
Reputation: 437698
The -Wait
switch of PowerShell's Start-Process
cmdlet also waits for child processes of the launched process to exit[1], whereas cmd.exe
's internal start
command does not.
Start-Process
also waiting for that (child) process to terminate indeed explains the hang.Here is a simple workaround:
cmd /c C:\updatefile.exe /VERYSILENT
When an executable is called via cmd /c
, cmd.exe
implicitly waits until the executable's process - and only it - terminates, even if it is a GUI application, just like start /wait
would.
Given the behavior described in footnote [1], another workaround is to use the -PassThru
switch with Start-Process
(instead of -Wait
) and pipe the result to Wait-Process
:
Start-Process -PassThru C:\updatefile.exe /VERYSILENT | Wait-Process
[1] See GitHub issue #15555, which also discusses that Wait-Process
acts differently in that only waits for the process itself to terminate.
As zett42 points out, the behavior of Start-Process -Wait
is now at least briefly mentioned in the docs as well (emphasis added): "waits for the specified process and its descendants".
Upvotes: 6
Reputation: 1
try
$arguments = "/Verysilent" Start-Process -wait C:\updatefile.exe -ArgumentList $arguments
Upvotes: -2