Click here to Skip to main content
15,892,674 members
Articles / Programming Languages / XML
Tip/Trick

EXE to MSI -- MSI Wrapper using WIX Toolset v4

Rate me:
Please Sign up or sign in to vote.
2.27/5 (3 votes)
3 Sep 2018CPOL1 min read 20.3K   2   2
WIX template for wrapping EXE with a MSI installer for easier deployment with group policy

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.

XML
<?xml version="1.0" encoding="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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionadditional information Pin
Nelek2-Sep-18 11:21
protectorNelek2-Sep-18 11:21 
SuggestionWrong type Pin
Afzaal Ahmad Zeeshan2-Sep-18 11:17
professionalAfzaal Ahmad Zeeshan2-Sep-18 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.