1

I am using Wix 3.8.

At first, I create an installer (.msi) that executes a custom action during installation process (for test purposes it only shows a message):

Product Element:

<Product Id="PUT-GUID-HERE" Name="MyProduct" 
         Version="1.0.1.100" Manufacturer="Foobar Company"
         UpgradeCode="PUT-GUID-HERE">

Custom Action

<CustomAction Id="Message1" Script="vbscript">
<![CDATA[
MsgBox("First Install?")
]]>
</CustomAction>

<InstallExecuteSequence>
<Custom Action="Message1" 
        Before="InstallInitialize">NOT Installed AND NOT REMOVE</Custom>

Now when I execute my .msi file, the message will be shown on my installation:

message box

At next, I modify my product code and increase my version number to build an update:

Product Element:

<Product Id="PUT-GUID-HERE" 
         Name="MyProduct" Version="1.0.2.100" 
         Manufacturer="Foobar Company" 
         UpgradeCode="PUT-GUID-HERE">

Regarding the condition NOT Installed AND NOT REMOVE I expect, that the message box does not appear when I execetue the update. But it does:

message box

What is the correct condition for a custom action that only will be executed on install but not on update?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Simon
  • 4,157
  • 2
  • 46
  • 87

2 Answers2

3

Be careful with the conditions on custom actions, they are complicated to get right. Here is a MSI Conditions Cheat Sheet to help you. I have not tested these conditions - testing is the only guarantee. Here is another sheet with more advanced info (recommended).

Here is an interesting post: How to add a WiX custom action that happens only on uninstall (via MSI)?

Your suggested condition looks ok, but have a look at the sheet. Also - a patch features patch-specific properties such as PATCH and MSIPATCHREMOVE. Use these conditions on custom actions to make them run or not run during a patch depending on what is necessary. If you plan to use patches you should condition your custom actions to not run during patching in my opinion.

I eliminated the hard coded guids for you. Be careful posting guids - with a simple copy and paste your unique guids are not so unique any more. Genuine problems could result from all hard coded guids.

Community
  • 1
  • 1
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
2

Finally it woks with following condition:

NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE) AND NOT (REMOVE="ALL")

Using this condition, my action only reacts on install, but not on update and not on uninstall.

Important: The .msi of both, the installer and update must contain that condition.

Simon
  • 4,157
  • 2
  • 46
  • 87
  • That condition may be incorrect because it does not include Repair, and note that despite what you may have heard you can't really guarantee you'll never get a repair. IMO the condition you need is just a plain old "Not Installed" . Then it will never run again. – PhilDW Sep 06 '14 at 18:34
  • 1
    @PhilDW: Your suggestion with "Not Installed" is wrong. When I make an update, the action will be executed → I have tested it. – Simon Sep 08 '14 at 08:35
  • What does "update" mean? During a patch, major upgrade, repair, and minor update the property Installed is always set because that product defined by that ProductCode is still installed. I've used it in this way many times, so there may be something different about your update. – PhilDW Sep 09 '14 at 19:45