Search code examples
wixwindows-installerwix3.5wix3.7advanced-installer

how to add command line parameter in Wix


I have been looking for a good answer for my following simple enough question.

I have an interactive Wix installer, which works perfect. The user needs to accept the licence agreement in the interactive setup to carry on the setup. Now, I need to have a silent installer where the user will accept the same licence agreement by entering a command line parameter like ACCEPT-EULA=YES. Could anyone please guide me how I should manage to implement this in wxs file? I am not using MSVC by the way. I have tried

<util:XmlFile Action="setValue" ...

but got tons of different sort of errors.

I'd greatly appreciate any help. Thanks.


Solution

  • You want an error custom action scheduled first in the install execute sequence with a condition of UILevel < 5 and Not ACCEPTEULA~="YES"`

    The UILevel property is defined here. 5 means full UI so you don't want this CA to run. < 5 means some form of silent installation so you only want this custom action to fire when the property doesn't equal (case insensitive) "yes".

    <CustomAction Id="RequireEulaWhenSilent" Error="You must accept the EULA by passing ACCEPTEULA=YES when performing a silent installation."/>
    <InstallExecuteSequence>
      <Custom Action="RequireEulaWhenSilent" Before="AppSearch"><![CDATA[UILevel<5 and Not ACCEPTEULA~="YES" and Not Installed]]></Custom>
    </InstallExecuteSequence>
    

    Of course you now have a problem that if they aren't logging the install they won't know why the installer failed. Personally I think this is an invented requirement by upper management and I always push back when given this problem. Otherwise you get into crazy land like this.