How to execute custom action only in install (not uninstall)

后端 未结 5 1785
栀梦
栀梦 2020-11-30 17:35

I\'m sure this is fairly easy, but I\'ve kind of had a hard time with it. I\'ve got a custom action that executes a different (non-msi) installer on installation. Unfortunat

相关标签:
5条回答
  • 2020-11-30 17:44

    A condition on the custom action, probably with a matching custom action to do the uninstall. Not sure what tools you're using, but assuming the secondary install is tied to a component, I would use that component state. A state of =3 means a target state of installed. A state = 2 means a target state of absent. Note that the state won't be set if there is no change.

    0 讨论(0)
  • 2020-11-30 17:45

    A bit of a correction:

    Finally, to only run an action during uninstall use the following condition: REMOVE="ALL"

    This seems more appropriate as the property REMOVE contains the features being uninstalled.
    So if I do a modify to remove one feature, REMOVE is true and the action that was to execute only on uninstall executes on modify.
    More details here on MSDN

    0 讨论(0)
  • 2020-11-30 17:46

    Please be careful with REMOVE=ALL. It is not available before installvalidate sequence.
    And check below links for more details:
    http://msdn.microsoft.com/en-us/library/aa371194(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/library/aa368013(v=vs.85).aspx

    0 讨论(0)
  • 2020-11-30 17:53

    An example:

    <InstallExecuteSequence>
    ..
        <Custom Action="QtExecIdOfCA" Before="InstallFinalize">NOT Installed</Custom>
    ..
    </InstallExecuteSequence>
    
    ..
    ..
    <CustomAction Id="QtExecIdOfCA" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
    

    Notice! Condition is added to the <Custom> tag and not the <CustomAction> it confused me, because Custom is followed by Action attribue

    0 讨论(0)
  • 2020-11-30 17:57

    Add a condition on the action so it's only triggered during installation, not uninstallation.

    Action run only during Install

    NOT Installed AND NOT PATCH
    

    Action runs during Install and repair

    NOT REMOVE
    

    Run on initial installation only:

    NOT Installed
    

    Run on initial install or when repair is selected.

    NOT Installed OR MaintenanceMode="Modify"
    

    To only run an action during uninstall use the following condition:

    REMOVE~="ALL"
    

    To only run an action during upgrade:

    Installed AND NOT REMOVE
    
    0 讨论(0)
提交回复
热议问题