Endlocal
If the command extension is enabled, endlocal changes as follows:
If the corresponding setLocal uses new EnableExtensions or
disableextensions option enables or deactivate the command extension, then after
endlocal, the enable / deactivation status of the command extension will be restored to the execution
The status of the corresponding setlocal command.
Definition
-
must use endlocal in the script or batch file. This command is invalid if you use endlocal outside the script or batch file.
-
has an implicit endlocal command at the end of the batch file.
-
By enabling a command extension (ie, the default), the endlocal command will be restored to the status of the command extension (ie, enabled or disabled) to execute the match setLocal command. status. For more information on enabling and disable the command extension, see the CMD in "Related Topics".
Nature
Repair
Application
setLocal after setLocal
SetLocal will open a temporary variable storage space All variables have been assigned, and modifications are temporary, and Endlocal is restored to setLocal. It is a bit similar to the relationship between global variables and local variables. For example:
@echo off
set a = 1
setlocal
set / a a + = 1
ECHO% a%
endlocal
ECHO% a%
pause
over batch processing will output
2
1