大网数据广告活动
安装更新与部署

Obtaining Context Information for Deferred Execution Custom Actions

· 52CE 我爱测

Because installation script can be executed outside of the installation session in which it was written, the session may no longer exist during execution of the installation script.

Because installation script can be executed outside of the installation session in which it was written, the session may no longer exist during execution of the installation script. In this case, the original session handle and properties set during the installation sequence are not available to a deferred execution custom action. Any functions that require a session handle are restricted to a few methods that can retrieve context information, or else properties that are needed during script execution must be written into the installation script. For example, deferred custom actions that call dynamic-link libraries (DLLs) pass a handle which can only be used to obtain a very limited amount of information. Functions that do not require a session handle can be accessed from a deferred custom action.

Deferred execution custom actions are restricted to calling only the following functions requiring a handle.

Function Description
MsiGetProperty Supports a limited set of properties when used with deferred execution custom actions: the CustomActionData property, ProductCode property, and UserSID property.Commit custom actions cannot use the MsiGetProperty function to obtain the ProductCode property. Commit custom actions can use the CustomActionData property to obtain the product code.
MsiFormatRecord Supports a limited set of properties when used with deferred execution custom actions: the CustomActionData and ProductCode properties.
MsiGetMode When called from deferred execution custom actions, commit custom actions, or rollback custom actions, MsiGetMode returns True or False when requested to check the mode parameters MSIRUNMODE_SCHEDULED, MSIRUNMODE_COMMIT, or MSIRUNMODE_ROLLBACK. Requests to check any other run mode parameters from a deferred, commit, or rollback custom action returns False.
MsiGetLanguage The numeric language ID for the current product.Commit custom actions cannot use the MsiGetLanguage function. Commit custom actions can use the CustomActionData property to get the numeric language ID.
MsiProcessMessage Processes error or progress messages from the custom action.

A custom action that is written in JScript or VBScript requires the install Session object. This is of the type Session Object and the installer attaches it to the script with the name "Session". Because the Session object may not exist during an installation rollback, a deferred custom action written in script must use one of the following methods or properties of the Session object to retrieve its context.

Name Description
Mode Property Returns True for MSIRUNMODE_SCHEDULED only.
Property Property (Session Object) Returns the CustomActionData property, ProductCode property, or UserSID property.
Language Property (Session Object) Returns numeric language ID of the installation session.
Message Method Called to handle errors and progress.
Installer Property Returns the parent object, which is used for non-session functions such as registry access and installer configuration management.

Property values that are set at the time the installation sequence is processed into script may be unavailable at the time of script execution. Only the following limited set of properties is always accessible to custom actions during script execution.

Property name Description
CustomActionData Value at time custom action is processed in sequence table. The CustomActionData property is only available to deferred execution custom actions. Immediate custom actions do not have access to this property.
ProductCode Unique code for the product, a GUID string.
UserSID Set by the installer to the user's security identifier (SID).

If other property data is required by the deferred execution custom action, then their values must be stored in the installation script. This can be done by using a second custom action.

To write the value of a property into the installation script for use during a deferred execution custom action

  1. Insert a small custom action into the installation sequence that sets the property of interest to a property having the same name as the deferred execution custom action. For example, if the primary key for the deferred execution custom action is "MyAction" set a property named "MyAction" to the property X which you need to retrieve. You must set the "MyAction" property in the installation sequence before the "MyAction" custom action. Although any type of custom action can set the context data, the simplest method is to use a property assignment custom action (for example Custom Action Type 51).
  2. At the time when the installation sequence is processed, the installer will write the value of property X into the execution script as the value of the property CustomActionData.

Related topics

About Properties

Using Properties

Property Reference

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。