Endlocal command in Windows

The endlocal command ends the localization of the environment changes in a batch file, and restores the environment variables to their original values ​​before the corresponding setlocal command is run.

The endlocal command ends the localization of the environment changes in a batch file, and restores the environment variables to their original values ​​before the corresponding setlocal command is run.

For an example of how to use this command, please see the example below.

Endlocal command syntax

 endlocal 

Parameters

Parameter Description /? Show help at the command prompt.

Note

  1. The endlocal command has no effect outside the script or batch file.
  2. There is an implicit endlocal command at the end of each batch file.
  3. If the command extensions are enabled (command extensions are enabled by default), the endlocal command restores the state of the command extensions (that is, enabled or disabled) becomes the state before the corresponding setlocal command is run.

Note:

For more information on how to enable and disable command extensions, refer to the article about the Cmd command in Windows.

For example

You can localize environment variables in a batch file. For example, the following command line starts the super-application batch program on the network, passes the output to a file and displays that file in Notepad:

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

See more:

  1. The echo command in Windows
  2. Edit command in Windows
  3. Driverquery command in Windows
Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile