Click here to Skip to main content
13,797,212 members
Click here to Skip to main content
Add your own
alternative version

Stats

4.7K views
1 bookmarked
Posted 1 Sep 2018
Licenced CPOL

EXE to MSI -- MSI Wrapper using WIX Toolset v4

, 3 Sep 2018
Rate this:
Please Sign up or sign in to vote.
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 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)

Share

About the Author

JakeG
Unknown
No Biography provided

You may also be interested in...

Comments and Discussions

 
Questionadditional information Pin
Nelek2-Sep-18 12:21
protectorNelek2-Sep-18 12:21 
SuggestionWrong type Pin
Afzaal Ahmad Zeeshan2-Sep-18 12:17
mvpAfzaal Ahmad Zeeshan2-Sep-18 12:17 
The content on this post is not enough for it to be considered as an article, please change the type of this post to Tip/Trick, and then resubmit.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.181207.3 | Last Updated 4 Sep 2018
Article Copyright 2018 by JakeG
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid