CustomActionData in WiX with Deferred Custom Actions
Here is a major gotcha that you will encounter when you try to configure your product with deferred actions using configurable properties during the installation.
Deferred actions do NOT have access to the MSI session objects which means that if you try to get the value of a property set by the installer like:
Value = Session.Property( "Property1" )
in a VBScript custom action which is deferred, It will return null. Yes, you just lost the original value of Property1 during deferred custom actions.
Here is where CustomActionData comes to the rescue, let’s see how this works
Your deferred Custom Action:
<CustomAction Id=" MYCustomDeferredAction " Return="check" Execute="deferred" BinaryKey="MYVBSCRIPT" VBScriptCall=" MyVBScriptMethod" />
Now let’s create a new custom action which will run as immediate:
<!--Note I am passing 2 values delimted by a ‘,’ in this example--> <CustomAction Id=" SetCustomActionDataValue " Return="check" Property="MYCustomDeferredAction" Value=""[Value1]","[Value2]"" />
And in the InstallExecuteSequence place the CustomActionData custom action before the actual custom action is executed:
<Custom Action="SetCustomActionDataValue" After="CAction1"> <![CDATA[ ( Place any conditions here…)]]> </Custom> <Custom Action=" MYCustomDeferredAction " After=" SetCustomActionDataValue "> <![CDATA[ ( Place any conditions here…)]]> </Custom>
And now in the VBScript just do a split to parse out the 2 values from the CustomActionData and you are done!
' VBScript source code Delim = "," strArgs = Session.Property("CustomActionData") Args = Split( strArgs, Delim ) Value1 = Args(0) Value2= Args(1)