Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


Updated: January 21, 2005

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


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



Displays help at the command prompt.

  • 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.


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.



call superapp>c:\superapp.out


start notepad c:\superapp.out

Formatting legend


Format Meaning


Information that the user must supply


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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft