'Run WiX toolset action depending on selected features

For my software I created an WiX Toolset Installer. Now, I need to run an action depending if the user has selected a feature. In other words: I need to install/uninstall the npcap driver during installation. For or this I have downloaded the installer from their website. This is then copied to my installation folder.

<DirectoryRef Id="INSTALLFOLDER" FileSource="$(var.BasePath)">
   <Component Id="npcap" Guid="{21480817-8F27-46E0-B6B7-A52166B29BA8}">
      <File Id="npcap.exe" Name="npcap.exe" KeyPath="yes"
         Source="..\..\..\support\npcap-1.60.exe" />
   </Component>
</DirectoryRef>

To select/deselect the feature I use:

<Feature Id="NPcapFeature" Title="NPcap 1.60" Level="1">
  <ComponentRef Id="npcap" />
</Feature>

The installation is started using an action:

<CustomAction Id="InstallService"
                  Return="check" Impersonate="no" Execute="deferred" Directory="INSTALLFOLDER"
                  ExeCommand="[INSTALLFOLDER]\npcap.exe"/>

The only snippet I found for this was on SO, but it did not work:

<InstallExecuteSequence>
  <Custom Action="InstallService"   
          After="InstallFiles"><![CDATA[(&NPcapFeature=3)]]></Custom>
</InstallExecuteSequence>

How can I create an option to install any kind of third-party programs like npcap or is there a better solution for this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source