JSI Tip 2541. Windows 2000 environment varialbe delay expansion.

Jerold Schulman

June 27, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today

When the command processor reads a line of text, it expands any environment variables present.

You can direct the command processor to interpret !variable! as a delayed environment variable, to be expanded only when used.

Delayed expansions allows you to include variables in compound conditional statements, preventing them from being expanded before they are tested.

The delayed expansion can be configured using the CMD /V:ON and CMD /V:OFF switches or by using Regedt32 to navigate to:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftCommand Processor

Edit or Add Value name DelayedExpansion as a REG_DWORD data type. Set the data value to:

0 - Delayed expansion is NOT enabled. This is the default.

1 - Delayed expansion is supported.

NOTE: This Value Name can also be configured at HKEY_CURRENT_USER, which would take precedence over HKEY_LOCAL_MACHINE.

NOTE: The /V: command line switch takes precedence over the registry entries.


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like