title: Perform Custom Action Based on Mode - WIX
body: <p>We have created WIX installer for our application. Problem we are facing is:
  We have defined two different custom action (say ActionForInstall and ActionForUninstall) that we want to perform in following case:
  ActionForInstall : Should run while installation, product upgrade, maintenancemode (for both repair and modify)
  ActionForUninstall : Should run only for uninstallation.</p>
  
  <p>But we are not able to set proper condition. You can refer code :</p>
  
  <pre><code>&lt;Custom Action=ActionForInstall After='InstallFinalize' &gt; 
      (NOT Installed) OR (Installed AND ((MaintenanceMode = "Modify") OR (MaintenanceMode = "Repair")) AND (NOT (MaintenanceMode = "Remove"))) OR  ((UPGRADINGPRODUCTCODE) AND NOT(REMOVE ~= "ALL"))
  &lt;/Custom&gt;
  &lt;Custom Action=ActionForUninstall Before='InstallFinalize'&gt;
      Installed AND NOT UPGRADINGPRODUCTCODE
  &lt;/Custom&gt;
  </code></pre>
  
  <p>Please let us know what we have done wrong. Above code is calling InstallFinalize even for uninstall.</p>