setlocal

Begins localization of environment variables in a batch file. Each setlocal command must have an endlocal command to restore environment variables.

```setlocal
```

Setlocal permits you to change environment variables during the execution of a batch file; the environment variables are restored to their original values after an endlocal command is issued. Environment variable are not restored to their original values when a batch file ends without the endlocal command. You can have more than one setlocal/endlocal command in a batch program (recursion).

Example

You can localize environment variables in a batch file.

```@echo off
rem This program starts the superapp batch program on the network,
rem directs the output to a file, and displays the file