19

I have two custom actions, one of which I'd like to execute when my product is installed and the other when it is uninstalled.

My custom action is currently called from a merge module after the "InstallFinalize", but this happens for both install and uninstall. I've tried adding the "NOT INSTALLED AND NOT UPGRADINGPRODUCTCODE" condition, but that gave me an error:

Error 2762. Cannot write script record. Transaction not started.

I've also tried attaching to other actions (for example, UnpublishComponents), but I can't find any that are unique to install or uninstall.

How can I fix this problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alan Spark
  • 8,152
  • 8
  • 56
  • 91
  • possible duplicate of [How to add a WiX custom action that happens only on uninstall (via MSI)?](http://stackoverflow.com/questions/320921/how-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi) – Yan Sklyarenko Jul 02 '13 at 06:01

2 Answers2

25

Try next
1. Only for Installation:

<InstallExecuteSequence>
<Custom Action="SomeAction" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>

2. For Uninstall try to use: Rob's answer

UPGRADINGPRODUCTCODE property is set only during RemoveExistingProducts CA.

Community
  • 1
  • 1
Dimiano
  • 403
  • 5
  • 11
2

The variable “INSTALLED” should be using is “Installed”. Find more information regarding the Install and uninstall conditions in the Stack Overflow answer How to add a WiX custom action that happens only on uninstall (via MSI)?.

Community
  • 1
  • 1
Vinoth
  • 1,975
  • 21
  • 34