Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 224
Joshua Avatar asked May 12 '09 21:05

Joshua


People also ask

How do I wrap an exe file?

Run Windows Command Prompt (cmd) (in Windows 10: open the Start menu, type cmd and press Enter) and go to the folder where your EXE file is located. replace <file.exe> with the name of your .exe file and <target-folder> with the path to the folder where you want the . msi file to be extracted (for example C:\Folder).

Can you convert an exe to an MSI?

Convert EXE to MSI using a free utility Alternatively, you may use one of the free MSI converters, such as MSI Wrapper. MSI Wrapper allows to easily convert any .exe file into an MSI package, and also delivers premium features for software developers as part of its Pro offering.

Is MSI and exe same?

The main difference between the two extensions is their purpose. EXE is used mainly to indicate that the file is an executable one. In comparison, MSI indicates that the file is a Windows installer. While an MSI is used only with installers, this is not the case with EXE.

How do I use MSI wrapper?

Start the MSI Wrapper When you installed the MSI Wrapper a shortcut was created in your start menu. You can open your start menu and launch the MSI Wrapper from there. A welcome screen is displayed as the first page of the wizard that will guide you through the process of creating an MSI package.


1 Answers

Well, there is the free way and the $$$ way. I cannot document everything here, but this should get you started.

On a side note, yes, Windows Installer is a maddening technology. There are many times where I think a task will be straightforward, but it actually becomes complicated. You definitely have to immerse yourself to understand it.

In any case, here goes:

Free: WiX (here)

This is a free tool to generate MSI files from a set of XML configuration files. I'll leave you to find tutorials online, but here is the crux:

You can compress your EXE into the installer by using the following tag in the WXS file:

<Binary Id="MYEXE" src="<path to my exe?"/> 

Then you can create a custom action which launches your EXE file:

<CustomAction Id="EXECA_CALLMYEXE" Return="check" Execute="deferred" BinaryKey="MYEXE"       ExeCommand="my command line"/> 

Then you insert your custom action into the InstallExecuteSequence in the appropriate spot (I almost always run mine somewhere between InstallInitialize and InstallFinalize)

<InstallExecuteSequence>    <Custom Action="EXECA_CALLMYEXE" After="InstallInitialize"><![CDATA[Not REMOVE]]></Custom> 

$$$: Get InstallShield (HERE)

First create a "Basic MSI" project and make sure you say you want no setup.exe generated. You set this in the Release settings.

Then you essentially do the same thing as with WiX, but you have a UI for it.

  • You can specify your helper EXE file by using the Direct Editor and putting your EXE file in the 'Binary' table
  • You can create a custom action to launch that EXE file from the "Custom Actions" Node in the tree on the left
  • You can insert the custom action by selecting "Install Sequences" and putting it in the InstallExecuteSequence somewhere between InstallInitialize and InstallFinalize as I said before.

Sorry, I could not be more detailed, but this should be a good start.

like image 68
Mike Marshall Avatar answered Sep 21 '22 16:09

Mike Marshall