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

WriteEnvironmentStrings Action

· 52CE 我爱测

The WriteEnvironmentStrings action modifies the values of environment variables.

The WriteEnvironmentStrings action modifies the values of environment variables.

Environment variables do not change for the installation in progress when the WriteEnvironmentStrings action or RemoveEnvironmentStrings action are run. On Windows 2000, Windows Server 2003, Windows XP, and Windows Vista this information is stored in the registry and a WM_SETTINGCHANGE message is sent to notify the system of the changes when the installation completes. Another process can receive notification of the changes by handling these messages. No message is sent if a restart of the system is pending. A package can use the MsiSystemRebootPending property to check whether a system restart is pending.

The installer runs the WriteEnvironmentStrings action only during the installation or reinstallation of a component, and runs the RemoveEnvironmentStrings action only during the removal of a component.

Values are written or removed based on the selection of primary actions and modifiers. These are described in the following ActionData Messages section. Note that depending on the action specified, WriteEnvironmentStrings may remove variables, and RemoveEnvironmentStrings may add them based on the authoring of the Environment table.

Sequence Restrictions

The InstallValidate action must be executed before the RemoveEnvironmentStrings action. Because the WriteEnvironmentStrings action and RemoveEnvironmentStrings action are never both applied during an install or removal of a component, their relative sequence is not restricted.

ActionData Messages

Field Description of action data
[1] Name of the environment variable to modify.
[2] The environment variable value.
[3] This is a field of bit flags that specifies the action to be performed. Include only one bit for a primary action. There may be more than one modifier bit included in this field. See the following bit flag descriptions.

Bit Value Description of primary actions
0x1 Set. Sets the value of the environment variable in all cases. If this bit is combined with an Append or Prefix modifier bit, the action adds the value to any existing value in the variable.
0x2 Set. Sets the value if the variable is absent. If this bit is combined with an Append or Prefix modifier bit, the action adds the value to any existing value in the variable.
0x4 Remove. Removes the value from the variable. If this bit is combined with an Append or Prefix modifier bit, the value is removed from the existing string, if the value exists.

Bit Value Description of modifier
0x20000000 If this bit is set, actions are applied to the machine environment variables. If this bit is not set, actions are applied to the user's environment variables.
0x40000000 Append. This bit is optional. Do not set both the Append and Prefix modifiers.
0x80000000 Prefix. This bit is optional. Do not set both the Append and Prefix modifiers.

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)

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

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