Delayed environment variable expansion is NOT enabled by default. You can enable or disable delayed environment variable ...

Delayed environment variable expansion is NOT enabled by default.  You can enable or disable delayed environment variable expansion for a particular invocation of CMD.EXE with the /V:ON or /V:OFF switch.  You can enable or disable delayed expansion for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDIT.EXE:      HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion          and/or      HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion  to either 0x1 or 0x0.  The user specific setting takes precedence over the machine setting.  The command line switches take precedence over the registry settings.  If delayed environment variable expansion is enabled, then the exclamation character can be used to substitute the value of an environment variable at execution time.