skip to Main Content

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?

2

Answers


  1. 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.

    • As you note in a later comment, a service executable is launched by your installer at the end; given that services run indefinitely, 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".

    Login or Signup to reply.
  2. try

    $arguments = "/Verysilent"
    Start-Process -wait C:updatefile.exe -ArgumentList $arguments

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search