Begins localization of environment changes in a batch file.
changes made after SETLOCAL has been issued are local to the
ENDLOCAL must be issued to restore the previous settings.
When the end
of a batch script is reached, an implied ENDLOCAL is
executed for any
outstanding SETLOCAL commands issued by that batch script.
If Command Extensions are enabled SETLOCAL changes as
SETLOCAL batch command now accepts optional arguments:
ENABLEEXTENSIONS / DISABLEEXTENSIONS
enable or disable command processor extensions. See
CMD /? for details.
ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION
enable or disable delayed environment variable
expansion. See SET /? for details.
These modifications last until the matching ENDLOCAL
regardless of their setting prior to the SETLOCAL command.
The SETLOCAL command will set the ERRORLEVEL value if given
an argument. It will be zero if one of the two valid
is given and one otherwise. You can use this in batch
to determine if the extensions are available, using the
VERIFY OTHER 2>nul
IF ERRORLEVEL 1 echo Unable to enable extensions
This works because on old versions of CMD.EXE, SETLOCAL does
set the ERRORLEVEL value. The VERIFY command with a bad
initializes the ERRORLEVEL value to a non-zero value.