How To Execute InstallUtil With WIX 3.5

by Indra 12. September 2011 04:31

I need to execute InstallUtil.exe at the end of a MSI installation created using WIX.

At that moment this link is down (How to Invoke InstallUtil.exe in WiX Custom Action to Call Your Managed Installer Class).

I found out that what I need was Custom Action Type 34 (running an exe with a working directory) from these threads:

These are the code snippets incase the first link is down again.

 

<!-- create custom action -->
<CustomAction Id="AfterCopyingFiles" Directory="DirectoryID_Where_InstallUtil_Is_Copied"
        ExeCommand="[DirectoryID_Where_InstallUtil_Is_Copied]installutil.exe File_Containing_RunInstaller_Attribute.exe" Return="check" Impersonate="yes" Execute="deferred" />

<CustomAction Id="ForUninstall" Directory="DirectoryID_Where_InstallUtil_Is_Copied"
        ExeCommand="[DirectoryID_Where_InstallUtil_Is_Copied]installutil.exe /u File_Containing_RunInstaller_Attribute.exe" Return="check" Impersonate="yes" Execute="immediate" />

<!-- set when custom action will execute -->
<InstallExecuteSequence>
    <!--install-->
    <Custom Action="AfterCopyingFiles" After="InstallFiles">NOT Installed</Custom>
  
    <!--uninstall-->
    <Custom Action="ForUninstall" Before="RemoveFiles">REMOVE="ALL"</Custom>
</InstallExecuteSequence>

 

After reading Chapter 5 from WIX A Developers Guide to Windows Installer I found out 2 more ways to trigger an executable during installation:

  • Custom Action Type 2: using Binary element for storing executable in MSI.
  • Custom Action Type 18: using File element for copying the executable first to the target machine.

code snippet:

<CustomAction Id="CustomActionType2"
   BinaryKey="BinaryElementId_For_The_Executable"
   ExeCommand=""
   Execute="commit"
   Return="ignore" />

<CustomAction Id="CustomActionType18"
   FileKey="FileElementId_For_The_Executable"
   ExeCommand=""
   Execute="commit"
   Return="ignore" />

Tags: ,

Continuous Integration | WIX

Pingbacks and trackbacks (1)+

Comments are closed