Introduction
Just wanted to share a template I used for creating an MSI installer around a simple EXE installer using WIX Toolset v4. By passing cmd line arguments to the EXE, we can perform the install silently and it will roll back if the EXE install is unsuccessful.
Background
This is mostly information gathered from this site as well as other websites combined to give me what I needed. In this case, I needed to deploy inventory agents to all computers in my work company domain. I enjoy the ease of using windows group policy to deploy programs but you need an MSI installer to take advantage of this feature. So using Visual Studio 2017 and WIX Toolset v4\Visual Studio Extension, I was able to accomplish this.
I originally used this for Fusion Inventory Agent (http://fusioninventory.org/) and made installers for the x64 and x86. Deploying the agents was simple after that, all agent settings were supplied with cmd arguments in the MSI installer. Tested on Windows 7/8/10.
Using the Code
Add your own custom icon for the uninstaller in the add\remove programs window.
Otherwise, remove the 2 lines referring to icon.
Make sure to add the EXE in the main project directory so it can be compressed into the new MSI installer file.
Copy this template to your wix project file and change all bold text below to match your values.
Build and test!
**Make sure to "run as administrator" and\or with "compatibility mode" when running the installer manually under Window 10.
="1.0"="UTF-8"
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Product Id="*" Name="APPLICATION NAME MSI WRAPPER"
Language="1033" Version="1.0.0.0"
Manufacturer="company name"
UpgradeCode="00000000-YOUR-GUID-0264712d4b1e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="myapplication.cab" EmbedCab="yes" />
<Icon Id="icon.ico" SourceFile="icon.ico" />
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="APPLICATION NAME MSI WRAPPER" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="mysetup" />
</Feature>
<CustomAction Id="mysetup" FileKey="setup.exe" ExeCommand='/COMMANDLINE-PARAMATERS /S'
Execute="deferred" Impersonate="yes" Return="check" />
<InstallExecuteSequence>
<Custom Action="mysetup" Sequence="5401">NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="TempFolder" />
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="TempFolder">
<Component Id="mysetup" Guid="00000000-YOUR-GUID-bac606fc74a2">
<File Id="setup.exe" Source="YOUR-EXE-FILE.exe" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Points of Interest
Any input appreciated.
History
- 1st September, 2018: Initial version