Search code examples
wixcustom-action

Wix Run Custom Action When "Newer version is installed"


How can I setup custom action to run my app when installation finished with "newer version is already installed"?

What I want: If newer version is installed, just run it. Run application always except deleting.

My configuration:

<CustomAction Id="LaunchApplication" Directory='INSTALLFOLDER' ExeCommand="[INSTALLFOLDER]\MyApp.exe"
              Return="asyncNoWait" />

<InstallExecuteSequence>
  <Custom Action="LaunchApplication" After="InstallFinalize">NOT (REMOVE="ALL")</Custom>
</InstallExecuteSequence>

Thanks


Solution

  • Solved with logs: app.msi /l*v log.txt

    Working configuration:

    <CustomAction Id="LaunchApplication" Directory='INSTALLFOLDER' ExeCommand="[INSTALLFOLDER]\MyApp.exe"
                  Return="asyncNoWait" />
    <CustomAction Id="SetLaunchApplicationPath" Property="LaunchApplicationPath" Value="[ProgramFilesFolder][Manufacturer]\[ProductName]\MyApp.exe">
    </CustomAction>
    <CustomAction Id="LaunchApplicationOnDowngrade" ExeCommand="[SetLaunchApplicationPath]" Property="LaunchApplicationPath"
                  Return="asyncNoWait" />
    
    <InstallUISequence >
      <Custom Action="SetLaunchApplicationPath" After="FindRelatedProducts">WIX_DOWNGRADE_DETECTED</Custom>
      <Custom Action="LaunchApplicationOnDowngrade" After="SetLaunchApplicationPath">LaunchApplicationPath</Custom>
    </InstallUISequence>
    <InstallExecuteSequence>
      <Custom Action="LaunchApplication" After="InstallFinalize" >NOT (REMOVE="ALL")</Custom>
    </InstallExecuteSequence>
    

    Action LaunchApplication executes when install/update finished Action LaunchApplicationOnDowngrade executes when install failed when newer version of product is found by FindRelatedProducts Action

    I use <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> to configure upgrade.