Export (0) Print
Expand All
Arp
At
Cls
Cmd
Fc
For
Ftp
If
Lpq
Lpr
Mmc
Rcp
Reg
Rem
Rsh
Rsm
SC
Set
Ver
Vol
Expand Minimize

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

Cmd

Command-line reference A-Z

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft