Generally, you can't retrieve the value of a property when running a custom action in deferred mode because of the security model Microsoft uses in the Windows Installer service.
There are exceptions however. The ProductCode and UserSID properties can be referenced directly in VB script in deferred mode. To reference any other property in VB script, use the CustomActionData property to pass the value of the property of interest. To do this, create a second custom action in the Execute Immediate sequence to pass the value of the CustomActionData property. Use this method to obtain the value of only one property, not multiple properties.
The following example shows the steps necessary to use the value of the INSTALLDIR property in a VB script executed in deferred mode. You can obtain the value of any other property in the same way.
1. Create a Call VBScript custom action in the Execute Deferred sequence of the .MSI script. Select one of the four choices for calling a VB Script, 'Call VBScript From Embedded Code', 'Call VBScript From Installation', 'Call VBScript From Installed Files', and 'Call VBScript From Property'. The Scheduling Options and Processing Options do not need altering from the default settings.
2. Name the Call VB Script custom action, "VBSCRIPTACTION". Be sure to use all capital letters. By using all capital letters, the custom action becomes a public property.
3. Create a Set Property custom action in the Execute Immediate sequence of the .MSI script. Set the property of your Execute Deferred custom action to the value of the property of interest. Enter the following in the fields of the Set Property dialog:
* Custom Action Name: Action (Enter any name you like)
* Property: VBSCRIPTACTION (Enter the name of the Execute Deferred custom action to call your VB script.)
* Property Value: [INSTALLDIR] (Enter the property surrounded by brackets to pass the value to your Execute Deferred custom action.)
4. To reference the value of INSTALLDIR in your VB script, use CustomActionData to determine the value of the INSTALLDIR property. Use the following VB script code to display the value of the property passed through CustomActionData:
Msgbox "Value of INSTALLDIR = " & Session.Property("CustomActionData")
- If you are using the custom action, "Call VBScript From Embedded Code", add the following to the beginning of the sample script: Call prop().
- If you are using any of the other three ways of calling a VBScript in the installation, then you cut and paste the script. The Call VBScript custom actions, 'Call VBScript From Installation', 'Call VBScript From Installed Files', and 'Call VBScript From Property', provides a field, Script Function Call, to enter the name of a VBScript function. Enter "prop" in the Script Function Call field to use the sample function in this Knowledgebase article.
- In Wise for Windows Installer 6.2, Call VBScript stored in a Custom Action provides the same functionality as Call VBScript from Embedded Code.
For more information about deferring custom actions, please see the topics titled "Obtaining Context Information for Deferred Execution Custom Actions" in the Windows Installer SDK.