Search code examples
installationwindows-installer

How to make an MSI that simply wraps an EXE file


After way too many experiments, I've come to the conclusion that Windows Installer is simply bad technology. But the customers want MSI files.

So, how can I create an MSI file that extracts an EXE file to a temporary directory and runs it with options same or similar as were passed to the EXE file?

Options to an MSI are explained in Msiexec (command-line options) (low level "run" of an MSI is msiexec option package.msi).

EDIT: mjmarsh's WiX solution looks like it works. I just haven't had a chance to try it yet (crunch time). If it works, I'll be accepting it.

EDIT: it does not work. Missing piece: attended/unattended does not seem to be available.

Anyway, the only to make this work at all would be for the custom action to kill its parent process!

EDIT: So somebody posted as a further answer wrapping the whole thing as a post-install custom action. Theoretically possible but since a reboot may be required (thanks MS for .NET 4 requiring a reboot sometimes) we have to do further hackery. So from the matrix of advantages:

Transparency: No. One big custom action.
Customizability: No.
Standardization: No. 
Management and reporting: No. Appears to work but will not.
Security: No benefit.
Validation: No. The hackery required to survive reboot makes this sure to not work.
Resiliency: Completely defeated.
Rollback: No. Rollback didn't work when we were using MSI anyway.
Patching & Updates: No. We have a local solution anyway.
Logging: No. Appears to work but will not.

No point.


Solution

  • Adding to weir's answer, change the custom action attribute like below:

    <!--Run Action-->
        <CustomAction Id="RunWrappedExe"
                      Return="asyncNoWait"
                      FileKey="ApplicationFileId"
                      Execute="deferred"
                      ExeCommand=""
                      HideTarget="no"
                      Impersonate="yes"/>
    

    Setting Return=asyncNoWai does not wait for the exe to return. The installer does it's job and closes normally. Meanwhile, the exe continous its execution.

    -Madhuresh