How to detect Silent Install from WiX Installer

Microsoft’s Windows Installer has a built-in property UILevel upon User Interactive level.

The Wix Condition element can be specified for components, controls, features, and products. This UILevel Property will be used with Condition, and also with Custom Action. By using the property, the Silent mode can be detected and installation logic can be managed.

Understand Property UILevel

The following table was from a Microsoft document explaining UILevel Property. The property defines the User Interface level that can be used to detect installation mode of Silent, Basic, Reduce UI, or Full UI Level.

INSTALLUILEVELNumeric valueUser interface level
INSTALLUILEVEL_NONE2Completely silent installation.
INSTALLUILEVEL_BASIC3Simple progress and error handling.
INSTALLUILEVEL_REDUCED4Authored UI, wizard dialogs suppressed.
INSTALLUILEVEL_FULL5Authored UI with wizards, progress, errors.

Open wix source, and add the Conditions for UILevel

Case 1.

Run “Custom Action” only for Silent or Basic mode. If you want to run in Silent mode only, UILevel = 2 can be used.

<InstallExecuteSequence>

    <Custom Action="RunCustomActionAOnlyForSilent" Before="InstallFinalize"><![CDATA[ UILevel < 4 ]]></Custom>

</InstallExecuteSequence>
Case 2.

Add a UILevel Condition to a Component.

      <Directory Id="DesktopFolder" Name="Desktop">
         <Component Id="AShortcutDesktop" Guid="88c3b696-04c8-481d-b361-0b1417ffb481">
          <Condition><![CDATA[ UILevel < 4 ]]></Condition>

        </Component>

      </Directory>
Case 3.

Add a UILevel Condition to Feature Element.

      <Feature Id='FeatureA' Level='2'>
           <Condition Level="1"><![CDATA[ UILevel < 4 ]]></Condition>
           <ComponentGroupRef Id="ComponentGroupA" />

      </Feature>

More articles to read:

How to Create WiX Project in Visual Studio 2022

How to Create Launch Conditions in WiX Installer

How to Create Desktop and Start Menu Shortcuts in WiX Installer

How to Install Window Services Using WiX

Leave a Comment