How to set a Property using an Environment Variable

How to set a Property based of the value of another Property

Custom Action Type 51


What the Frel is a Custom Action Type?

Custom Action Types are the building blocks of MSI. The ones used most often appear in the Actions column of MSI Script tab inside the Windows Installer Editor. Once in a while you might want an Action that is not in the list. This is where you must add them manually as shown below.


You cannot set a property based of the value of another property. This is necessary to prevent creating circular references in the Property table (aka which gets its value first). Instead, you can set one property based on another by using a Custom Action Type 51. (It's in the SDK, click )

This custom action sets a property from a formatted text string.

To affect a property used in a condition on a component or feature, the custom action must come before the CostFinalize action in the action sequence.


The Wise KB Article #1156 and Wise KB Article #1957 hint as to how to do it but the feature to add new a Custom Action as described is broken in WPS4.62 and WPS5.1! (Specifically the Right-click on All Custom Actions, and select New --> Custom Action doesn't work.) Here is the workaround:


Example: Settings a Property to the value of an Environment Variable

Go to the Setup Editor view:

-Click the Tables tab

-Add a row to the CustomAction Table manually


Go to the MSI Script view:

-Actions tab --> All Custom Actions


-Select the Custom Action that we created in the tables.


-Double-click on it

By using the SDK (look up "Custom Action Type 51") and the snapshot above, we deduce:

-Property (aka source in the SDK) is the Property we want to set.

-Property Value (aka the target in the SDK) is the string that we use to set it with.


To be based on another MSI Property, set the Property Value string to [OTHERPROPERTY]

You can also combine 2 Properties together like this {[PROP1][PROP2]}

There are a few other things you can put here by looking up FORMATTED in the SDK.

Frame37


-Click on the Location tab

-Uncheck the No Sequence box

-Select CostFinalize and click the Add button

-Make sure that this action occurs before the CostFinalize action. (use the Move Up and Move Down button if necessary)

-Click Ok and we are done!