ENDLOCAL — Restore the saved copy of the environment variables

Synopsis

ENDLOCAL [/?]

Options

/?
Display command syntax information.

Description

The ENDLOCAL command restores the saved copy of the environment variables that was saved by the SETLOCAL command. The saved copy is then discarded. If there is no saved copy to restore, the ENDLOCAL command does nothing.

It is possible to preserve the changed values of specific environment variables across an ENDLOCAL command, by taking advantage of the fact that variable substitution occurs once for an entire command line. Simply include a SETENV command on the same line as the ENDLOCAL command, setting the required variable to its own expanded value. The variable substitution across the command line will substitute the changed value of the variable, before the ENDLOCAL command is executed to restore the original value, resulting in the SETENV command setting the variable back to its new value.

endlocal&setenv PRESERVED "%PRESERVED%"

SETLOCAL


The 32-bit Command Interpreter is © Copyright Jonathan de Boyne Pollard. "Moral" rights are asserted.