Share via


Endlocal

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Endlocal

Ends localization of environment changes in a batch file, restoring environment variables to their values before the matching setlocal command.

Syntax

endlocal

Parameters
  • /?
    Displays help at the command prompt.
Remarks
  • You must use endlocal in a script or batch file. If you use endlocal outside of a script or batch file, it has no effect.

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

  • With command extensions enabled (that is, the default), the endlocal command restores the state of command extensions (that is, enabled or disabled) to what it was before the matching setlocal command was run. For more information about enabling and disabling command extensions, see cmd in Related Topics.

Examples

You can localize environment variables in a batch file. For example:

@echo off

rem This program starts the superapp batch program on the network,

rem directs the output to a file, and displays the file

rem in Notepad.

Setlocal

path=g:\programs\superapp;%path%

call superapp>c:\superapp.out

endlocal

start notepad c:\superapp.out

Formatting legend

Format Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

See Also

Concepts

Cmd
Command-line reference A-Z
Command shell overview