SETLOCAL command

The SETLOCAL command allows setting local environment and changing pBat interpretors settings at runtime.

To revert modifications to environment after a SETLOCAL command, use the ENDLOCAL command.

Synopsis

SETLOCAL [ENABLEDELAYEDEXPANSION | DISABLEDELAYEDEXPANSION] [CMDLYCORRECT | CMDLYINCORRECT]

Create a local environment so that changes to variables after the SETLOCAL command be discarded using the ENDLOCAL command. The option that can be specified allow enabling or disabling following modes :

When calling SETLOCAL, the %ERRORLEVEL% variable is left unmodified, except if an error occurs, then %ERRORLEVEL% will be set to -1.

Compatibility

Fully compatible with cmd.exe since 218.2. ENABLEEXTENSION and DISABLEEXTENSIONS are ignored by pBat, every extensions is enabled at startup.

See also

ENDLOCAL command, SET Command, Commands list