GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing ss64.com — Setlocal - Local variables command - Windows CMD SETLOCALSet options to control the visibility of environment variables in a batch file. Syntax
SETLOCAL
SETLOCAL {EnableDelayedExpansion | DisableDelayedExpansion} {EnableExtensions | DisableExtensions}
Key
EnableDelayedExpansion Expand variables at execution time rather than at parse time.
DisableDelayedExpansion Expand variables at parse time rather than at execution time.
EnableExtensions Attempt to enable Command extensions.
DisableExtensions Attempt to disable Command extensions.
SETLOCAL on its own, usually at the start of a batch file, will begin localisation of Environment Variables. Issuing a SETLOCAL command, the batch script will inherit all current variables from the master environment/session. Issuing an ENDLOCAL command will restore all environment variables to the state they had before the SETLOCAL was issued. If a batch script does not use SETLOCAL then all variables will be Global, i.e. visible and modifiable by other scripts. Although global variables are easy to work with they are not good practice, for example if you have several batch scripts dealing with filenames (and these scripts are CALLing one another), the first script has a variable called _filename, the second script a different variable called file-name (a different name to avoid conflicting with the first script) a third script now needs something like file_name this quickly becomes very difficult to manage. With local variables you are free to use the same variable names in multiple batch scripts - there is no conflict because the local variables are not visible to any other script. EnableDelayedExpansion
DisableDelayedExpansion
Overloading a variable:
ErrorLevel
EnableExtensions / DisableExtensions
SETLOCAL is an internal command. “A local shop for local people” ~ The League Of Gentlemen Related commandsENDLOCAL - End localisation of environment changes in a batch file. Copyright © 1999-2026 SS64.com
Some rights reserved |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |