0

I am using the following code to start a Setup program at the end of my Installation (also with elevated permissions):

 <Product ... >
 ...

<InstallExecuteSequence>
  <Custom Action='LaunchSetupAction' After='InstallFinalize'/>
</InstallExecuteSequence>

<!-- Workaround required for Windows7, Setup.exe can not be started directly because of UAC
http://stackoverflow.com/questions/2325459/executing-a-custom-action-that-requires-elevation-after-install -->
<Property Id="WixShellExecTarget" Value='[#SetupEXE]'/>
<CustomAction Id="LaunchSetupAction" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes"/>

...

<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

</Product>

This works well when then program is installed freshly, but when it is upgraded from a previous version with the same code, the installation reports a fatal error and fails.

In the Windows installer log I have found the following:

 Action start 23:42:22: LaunchSetupAction.
 ...
 MSI (s) (38:88) [23:42:22:342]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI679.tmp, Entrypoint: WixShellExec
...
WixShellExec:  WixShellExecTarget is C:\Program Files\Me\MySetup.exe
...
WixShellExec:  Error 0x80070002: ShellExec failed with return code 2
...
WixShellExec:  Error 0x80070002: failed to launch target
...
Action ended 23:42:22: LaunchSetupAction. Return value 3.
Action ended 23:42:22: INSTALL. Return value 3.

Interesting enough these error messages (file not found?) is also there when I comment out the CustomAction in the new version of the installer.

  • Why is this CustomAcount executed from the previous version to be uninstalled?

  • Is there any way I can stop it from being run? After a certain point of the upgrade, the MySetup.exe is just not there anymore and will always cause a fatal error ...

LeRookie
  • 311
  • 3
  • 12

1 Answers1

0

That custom action has no condition on it, so it will be called on all types of installer operations, such as uninstall, add/remove features etc. Your upgrade is an install of the new product and an uninstall of the old product.

You need this kind of thing on your custom action:

Wix: Run custom action based on condition

so a condition of 'Not Installed' causes the CA to run only if the product is not already installed.

You can't really fix this because the uninstall for that product is embedded in the system. You'd need to fix that older version of the product by rebuilding the exact same product with the custom action condition fixed and then fix it with:

msiexec /i [path to new MSI] REINSTALL=ALL REINSTALLMODE=vomus

If you're very familiar with MSI and Orca, you may be able to locate the cached MSI file in C:\windows\installer, open it with Orca, go the InstallExecuteSequence and give that custom action a condition of 0, then save it. That basically corrects the uninstall sequence so that your upgrade will work. Caveat Emptor.

It also appears that a plain uninstall would give you same error - did you every try to do an uninstall test?

Community
  • 1
  • 1
PhilDW
  • 20,260
  • 1
  • 18
  • 28