DelayedExpansion Entry

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

DelayedExpansion

HKCU\Software\Microsoft\Command Processor

Data type Range Default value

REG_DWORD

0 | 1

0

Description

Specifies whether the command processor, Cmd.exe, supports delayed expansion of environment variables. If the value of this entry isĀ 1, then the Cmd.exe interprets an exclamation point (!) as an environment variable that is expanded only when used.

By default, Cmd.exe expands variables when it reads a line of text. However, you can direct Cmd.exe to expand a variable only when it is used. If you do this, you can include variables in compound conditional statements and prevent them from being set before they are tested.

Value Meaning

0

Delayed expansion is not supported. Cmd.exe expands environment variables when it reads them, and it does not interpret exclamation points as delayed variables.

1

Delayed expansion is supported. The system expands environment variables surrounded by exclamation points, such as !VAR!, only when they are used.

Change Method

You can change the value of this entry by using Cmd.exe and typing cmd /v:on, but only for the duration of that Cmd.exe's execution. For all other changes, you must use the registry editor Regedit.exe.

Activation Method

If you make changes to the value of this entry by using Regedit.exe, then you must restart Cmd.exe to make the changes effective.

Notes

  • DelayedExpansion can appear in HKLM and in HKCU. If both appear in the registry, the value of the entry in HKCU takes precedence over the value in HKLM.

  • The datatype of this entry can be either REG_DWORD or REG_SZ.

  • This entry does not exist in the registry by default. You can add it by using the registry editor Regedit.exe. Even when this entry appears in the registry, the setting of the command-line parameter /v takes precedence over it.

Tip

  • For more details, run Cmd.exe and type help set or cmd /?, and read the entry on the /v command.

See Also

Concepts

Command Processor\DelayedExpansion