Search code examples
wixwixsharp

Is launch Condition shown in silent mode?


Using WixSharp to build installer,

Is LaunchCondition shown when running in silent mode? (e.g "msiexec /i /qn /quiet")


Solution

  • MSI GUI: MSI has many UILevels - degrees of visible GUI (more on this here). When a setup is run in silent mode, any errors from Launch Conditions will show up in the MSI log instead of a dialog.

    This makes sense since you must avoid dialogs showing up when there might be nobody to dismiss them (for example in automatic package deployment systems).

    Essentially you can run with basic GUI /qb or reduced GUI /qr or completely silently /qn. When you run silently no dialogs should be shown, and you should consult the log file for results:

    Silent MSI installation:

    msiexec /i MySetup.msi /qn /L test.log
    

    Test Project: https://github.com/glytzhkof/WiXLaunchConditionTest (MYVALUE is defined in the Property table - change it there to 0 or 1).

    Here is a sample log output:

    === Logging started: 28.10.2021  13:07:12 ===
    Action start 13:07:12: INSTALL.
    Action start 13:07:12: FindRelatedProducts.
    Action ended 13:07:12: FindRelatedProducts. Return value 1.
    Action start 13:07:12: LaunchConditions.
    MSI (s) (F4:DC) [13:07:12:491]: Product: WiXLaunchConditionTest -- Value for MYFLAG must be 1 (true) or 0 (false)
    
    Value for MYFLAG must be 1 (true) or 0 (false)
    Action ended 13:07:12: LaunchConditions. Return value 3.
    Action ended 13:07:12: INSTALL. Return value 3.
    MSI (s) (F4:DC) [13:07:12:493]: Product: WiXLaunchConditionTest -- Installation failed.
    
    MSI (s) (F4:DC) [13:07:12:493]: Windows Installer installerte produktet. Produktnavn: WiXLaunchConditionTest. Produktversjon: 1.0.0.0. Produktspråk: 1033. Produsent: -. Installasjonens resultatstatus: 1603.
    
    === Logging stopped: 28.10.2021  13:07:12 ===
    

    Admin Rights: It should be noted that an MSI should be run from a cmd.exe with admin rights - or you get no message from the silent installer that the setup failed because of lacking admin rights (the failure is from lacking admin rights, not because of the launch conditions).

    This registry script adds context menus in Windows Explorer which can open a cmd.exe in any folder with or without admin rights: https://github.com/glytzhkof/all/blob/master/HKCU_Run-CMD-Shell-Extension.reg. Just merge the registry file and then right click an empty space inside Windows Explorer in any folder. See the commands towards the bottom of the dialog:

    Windows Explorer Context Menu