JSI Tip 2541. Windows 2000 environment varialbe delay expansion.
June 27, 2000
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.
About the Author
You May Also Like