Take the 2-minute tour ×

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.

share|improve this question
So, a lot of people are looking at this. Unfortunately there is no solution, and most of the developers are now in favor of not using MSI period. –  Joshua Jul 29 '10 at 22:34
+1 for the first statement –  kizzx2 Nov 29 '10 at 13:37
It is entirely possible to run an EXE file during an MSI install, and I have done so several times. It is just a matter of sequencing and verifying that the EXE you run exits cleanly. MSI is generally hard to deal with and often requires specialist attention, but the benefit in terms of corporate deployment is very substantial. MSI does enforce a number of rules that make it hard to do unusual and dangeropus things during installation. –  Stein Åsmul May 18 '11 at 2:03
Glytzhkof: try invoking from inside a MSI a third-party EXE that's going to unpack and invoke several MSIs. –  Joshua May 18 '11 at 2:09
Please read: "Advantages of using MSI files" for a summary of the benefits provided by MSI files for corporate use. –  Stein Åsmul Jul 28 at 11:58

10 Answers 10

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)

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

share|improve this answer
The installshield way is already known not to work. It does not extract to a temp directory but to the target directory, running into the same bug we are trying to avoid in the first place (modify date on target file is often flat out wrong). –  Joshua May 12 '09 at 21:46
Looks like WiX can do it w/ Custom Action and Binary element. Unfortunately the tutorial is currently busted but the help file in the download binary works. –  Joshua May 12 '09 at 23:10
Huh, I was unaware of the binary extraction issue with IS. What version do you use? –  mjmarsh May 13 '09 at 15:24
We recently had a customer who reported getting a cryptic, undocumented error when running the installer we created with InstallShield. We re-packaged it as an MSI and it ran OK. We are abandoning InstallShield after years of frustration, and converting to WiX. –  Pierre Jun 16 '13 at 16:59

I think the easiest way to create a .MSI file is to use WiX.

Lesson 1 from the WiX tutorial is all you need to create a simple install.

share|improve this answer
That link is forbidden(403) now. Granted it is three years later. –  Ben L Dec 11 '12 at 23:00
I think the Lesson one should be wix.tramontana.co.hu/tutorial/getting-started. But I don't think it has to do with running a EXE from within MSI. –  wenqiang Jan 31 '13 at 7:13
up vote 4 down vote accepted

No solution. We went NSIS as corporate MSI install is going to be broken anyway due to MSI nesting problem (just try installing EXE wrapping MSI from inside MSI someday).

share|improve this answer
Just for the record, here is a summary of deployment tools and their strengths and weaknesses. For other people looking to decide how to do deployment. –  Stein Åsmul Jul 28 at 12:01
Please also read: "Advantages of using MSI files" for a summary of the benefits provided by MSI files for corporate use. –  Stein Åsmul Jul 28 at 12:02

Joshua, I understand your frustration very well. MSI is quirky to say the least - a completely new way to think of deployment. Still, applied correctly MSI offers the best possible deployment, especially for corporate customers.

What operations does your installer EXE perform? Is it largely file copy, some COM registration and some registry writes, or does it run complex installation logic, setting up databases etc...? The reason I ask is because it probably would be very quick to create a well functioning WIX MSI for you so you can abandon the EXE approach.

It is indeed possible to run an EXE from inside an MSI, but it requires proper sequencing, and it is guaranteed to cause you more blues than a simple MSI. If the app is small, and not doing anything crazy during installation, I would be happy to provide you with a basic WIX conversion.

share|improve this answer
MSI known bug: will not update executable binary that was touched by something else. –  Joshua Jun 30 '09 at 15:09
It is not clear to me why an executable binary should be "touched by something else" after deployment? Binaries should essentially be considered read-only after installation? –  Stein Åsmul May 18 '11 at 1:57
We never did find out what was doing it. –  Joshua May 18 '11 at 2:08
Joshua: very likely a recompiled binary with the same version set. You can deal with this in several ways. The easiest way is to set REINSTALLMODE="emus" in the msiexec.exe command line. This will replace files of equal or lower version (as opposed to the normal behavior of replace lower versions). I prefer to set automatic version updates for .NET assemblies though using 1.0.* in the project settings. –  Stein Åsmul Jul 28 at 12:06
Bad guess. We had auto number turned on. –  Joshua Jul 28 at 15:31

There is also a free version of the MSI Wrapper. It also supports uninstall and upgrades. Also, it only creates one entry in the Add or Remove programs.

share|improve this answer
What part of "Cannot fire EXE wrapped MSI from within another MSI" do people not understand? –  Joshua Feb 17 '13 at 20:05
Delete me wong place and I can't delete –  Joshua Oct 8 at 18:39

If you don't want to manage MSI, but only execute EXE, try Exe to MSI Converter Free. You just put in the path to the EXE and get an MSI.

share|improve this answer
Do you know what happens when an EXE that was invoked from a MSI invokes an exe that will invoke an MSI (such as .NET 4)? –  Joshua Jun 21 '12 at 16:00
No. I don't got this problem. My setup.exe was developed in Inno Setup works, but I don't call any msi from inside exe. –  pawelek Jun 25 '12 at 9:09
Then you won't have the problem. Take a working MSI (any MSI), wrap it in an EXE wrapper, then try using this tool to wrap that EXE in a MSI and watch the spectacular result. –  Joshua Jun 25 '12 at 15:59

try this:

In MSI package, there is a behaviour call "Launch an application after installation", that means your exe file will be executed after the MSI installation(the MSI is closed).

Try to execute your exe there, so when your exe invoke other MSI packages, it won't conflict with the first one.

share|improve this answer

Wix can do it. Here is my sample code for wix 3.5:

<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product Id='*' UpgradeCode="11111111-2222-3333-4444-555555555555" 
        Name='My Setup' Language='1033' Version='' 
        Manufacturer='Your company'>

    <Package Description='pak' InstallerVersion='200' Compressed='yes' />

    <Media Id='1' Cabinet='setup.cab' EmbedCab='yes' />

    <Directory Id='TARGETDIR' Name='SourceDir'>
        <Directory Id="TempFolder">
            <Directory Id="INSTALLLOCATION" Name="~_tmpdir">
                <Component Id='MyComponent' DiskId='1' Guid=''>
                    <File Id="File0" Name="setup.exe" Source="setup.exe" />
                    <File Id="File1" Name="file1.txt" Source="file1.txt" />

    <Feature Id='InstallFeature' Title='Install Feature' Level='1'>
        <ComponentRef Id='MyComponent' />

    <!-- Run Action -->
    <CustomAction Id="RunWrapExe" Return="ignore" Execute="deferred" 
                  FileKey="File0" ExeCommand="setup.exe param here"  
                  HideTarget="no" Impersonate="no" />

        <Custom Action="RunWrapExe" 
                After="InstallFiles">NOT REMOVE~="ALL"</Custom>

share|improve this answer
Doesn't work. Setup.exe might, depending on circumstances, execute the exe for SQLEXPRESS, which runs multiple MSIs. –  Joshua Nov 4 '11 at 15:16
Well, single exe can work, for me that will resove all. For all install file, we build with great [InnoSetup](www.jrsoftware.org/isinfo.php) to create a exe, and if customer want MSI, we'll packet exe with Wix. This way, there's only one setup script to maintain. –  weir Sep 26 '12 at 8:03

I was having the same problem (wrap EXE, call other MSI from the EXE including .net setup, etc.), and here is my solution:

I build the setup exe using InstallAware. It has its own MSI Wrapper that wraps the generated EXE with MSI.

It works OK, the EXE can call other MSIs without any problem (including .net setup, other 3rd party setups), but that is because the launching MSI ends ("returns") rights after it launches the setup EXE file, and that way they avoid the MSI limitation of recursive MSI calls.

BUT - some customers (companies) that uses MSI deployment tools, requires the MSI (msiexec) to return (end) only after the setup process ends, and that is a problem with the above solution.

So - to solve this:

There is another MSI Wrapper (exemsi.com) that generates MSI that returns only after the EXE setup ends, but for using that you must use another unique option of InstallAware:

InstallAware has the option to generate the EXE setup using their own native engine, and not based on Windows Installer engine, to avoid MSI recursive limitation. Combine those both, and you have the perfect solution.

Hope this will help someone, although many years passed since this question was first posted.

share|improve this answer
Apparently you haven't tried it with the custom .EXE running .NET setup. –  Joshua Dec 1 at 1:04

You can try out the ZOLA tool here : http://www.zolasoftware.com

share|improve this answer
So what does it do when the EXE tries to install a MSI? –  Joshua Oct 8 at 18:39

Your Answer


