endlocal

Ends localization of environment changes in a batch file, and restores environment variables to their values before the corresponding setlocal command was run.

Syntax

endlocal

Parameters

Parameter Description
/? Displays help at the command prompt.

Remarks

  • The endlocal command has no effect outside a script or batch file.

  • There is an implicit endlocal command at the end of a batch file.

  • If command extensions are enabled (command extensions are enabled by default), the endlocal command restores the state of command extensions (that is, enabled or disabled) to what it was before the corresponding setlocal command was run.

Note

For more information about enabling and disabling command extensions, see the Cmd command.

Examples

You can localize environment variables in a batch file. For example, the following program starts the superapp batch program on the network, directs the output to a file, and displays the file in Notepad:

@echo off
setlocal
path=g:\programs\superapp;%path%
call superapp>c:\superapp.out
endlocal
start notepad c:\superapp.out