Environment variable

An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer.

They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.

They were introduced in their modern form in 1979 with Version 7 Unix, so are included in all Unix operating system flavors and variants from that point onward including Linux and macOS. From PC DOS 2.0 in 1982, all succeeding Microsoft operating systems including Microsoft Windows, and OS/2 also have included them as a feature, although with somewhat different syntax, usage and standard variable names.

Design

In all Unix and Unix-like systems, each process has its own separate set of environment variables. By default, when a process is created, it inherits a duplicate environment of its parent process, except for explicit changes made by the parent when it creates the child. At the API level, these changes must be done between running fork and exec. Alternatively, from command shells such as bash, a user can change environment variables for a particular command invocation by indirectly invoking it via env or using the ENVIRONMENT_VARIABLE=VALUE <command> notation. A running program can access the values of environment variables for configuration purposes.

Shell scripts and batch files use environment variables to communicate data and preferences to child processes. They can also be used to store temporary values for reference later in a shell script. However, in Unix, other variables are usually used for this.

In Unix, an environment variable that is changed in a script or compiled program will only affect that process and possibly child processes. The parent process and any unrelated processes will not be affected. Similarly, changing or removing a variable's value inside a DOS batch file will change the variable for the duration of COMMAND.COM's existence.

In Unix, the environment variables are normally initialized during system startup by the system init scripts, and hence inherited by all other processes in the system. Users can, and often do, augment them in the profile script for the command shell they are using. In Microsoft Windows, each environment variable's default value is stored in the Windows Registry or set in the AUTOEXEC.BAT file.

On Unix, a setuid program is given an environment chosen by its caller, but it runs with different authority from its caller. The dynamic linker will usually load code from locations specified by the environment variables $LD_LIBRARY_PATH and $LD_PRELOAD and run it with the process's authority. If a setuid program did this, it would be insecure, because its caller could get it to run arbitrary code and hence misuse its authority. For this reason, libc unsets these environment variables at startup in a setuid process. setuid programs usually unset unknown environment variables and check others or set them to reasonable values.

Syntax

The variables can be used both in scripts and on the command line. They are usually referenced by putting special symbols in front of or around the variable name. For instance, to display the user home directory, in most scripting environments, the user has to type:

echo $HOME

In DOS, OS/2 and Windows command-line interpreters such as COMMAND.COM and cmd.exe, the user has to type this:

ECHO %HOME%

In Windows PowerShell, the user has to type this:

Write-Output $env:HOMEPATH

The commands env, set, and printenv display all environment variables and their values. printenv can also be used to print a single variable by giving that variable name as the sole argument to the command.

Assignment

The commands env and set are also used to set environment variables and are often incorporated directly into the shell.

Unix

In Unix, the following commands can also be used, but are often dependent on a certain shell.

VARIABLE=value         #
export VARIABLE        # for Bourne and related shells
export VARIABLE=value  # for ksh, bash, and related shells
setenv VARIABLE value  # for csh and related shells

A few simple principles govern how environment variables achieve their effect.

Environment variables are local to the process in which they were set. If two shell processes are spawned and the value of an environment variable is changed in one, that change will not be seen by the other.

When a child process is created, it inherits all the environment variables and their values from the parent process. Usually, when a program calls another program, it first creates a child process by forking, then the child adjusts the environment as needed and lastly the child replaces itself with the program to be called. This procedure gives the calling program control over the environment of the called program.

In Unix and Unix-like systems, the names of environment variables are case-sensitive.

In Unix shells, variables may be assigned without the export keyword. Variables defined in this way are displayed by the set command, but are not true environment variables, as they are stored only by the shell and not recognized by the kernel. The printenv command will not display them, and child processes do not inherit them.

VARIABLE=value

However, if used in front of a program to run, the variables will be added to the program's environment:[1]

VARIABLE=value program_name [arguments]

The persistence of an environment variable can be session-wide or system-wide.

unset is a builtin command implemented by both the Bourne shell family (sh, ksh, bash, etc.) and the C shell family (csh, tcsh, etc.) of Unix command line shells. It unsets a shell variable, removing it from memory and the shell's exported environment. It is implemented as a shell builtin, because it directly manipulates the internals of the shell.[2][3]

Read-only shell variables cannot be unset. If one tries to unset a read-only variable, the unset command will print an error message and return a non-zero exit code.

DOS, OS/2 and Windows

In DOS, OS/2 and Windows command-line interpreters such as COMMAND.COM and cmd.exe, the SET command is used to assign environment variables and values using the following arguments:

SET VARIABLE=value

The SET command without any arguments displays all environment variables along with their values.

Examples

Examples of environment variables include:

  • PATH: a list of directory paths. When the user types a command without providing the full path, this list is checked to see whether it contains a path that leads to the command.
  • HOME (Unix-like) and USERPROFILE (Microsoft Windows): indicate where a user's home directory is located in the file system.
  • HOME/{.AppName} (Unix-like) and APPDATA\{DeveloperName\AppName} (Microsoft Windows): for storing application settings. Many applications incorrectly use USERPROFILE for application settings in Windows: USERPROFILE should only be used in dialogs that allow user to choose between paths like Documents/Pictures/Downloads/Music; for programmatic purposes, APPDATA (for roaming application settings shared across multiple devices), LOCALAPPDATA (for local application settings) or PROGRAMDATA (for application settings shared between multiple OS users) should be used.[4]
  • TERM (Unix-like): specifies the type of computer terminal or terminal emulator being used (e.g., vt100 or dumb).
  • PS1 (Unix-like): specifies how the prompt is displayed in the Bourne shell and variants.
  • MAIL (Unix-like): used to indicate where a user's mail is to be found.
  • TEMP: location where processes can store temporary files.

True environment variables

Unix

$PATH
Contains a colon-separated list of directories that the shell searches for commands that do not contain a slash in their name (commands with slashes are interpreted as file names to execute, and the shell attempts to execute the files directly). It is equivalent to the DOS, OS/2 and Windows %PATH% variable.
$HOME
Contains the location of the user's home directory. Although the current user's home directory can also be found out through the C-functions getpwuid and getuid, $HOME is often used for convenience in various shell scripts (and other contexts). Using the environment variable also gives the user the possibility to point to another directory.
$PWD
This variable points to the current directory. Equivalent to the output of the command pwd when called without arguments.
$DISPLAY
Contains the identifier for the display that X11 programs should use by default.
$LD_LIBRARY_PATH
On many Unix systems with a dynamic linker, contains a colon-separated list of directories that the dynamic linker should search for shared objects when building a process image after exec, before searching in any other directories.
$LIBPATH or $SHLIB_PATH
Alternatives to $LD_LIBRARY_PATH typically used on older Unix versions.
$LANG, $LC_ALL, $LC_...
$LANG is used to set to the default locale. For example, if the locale values are pt_BR, then the language is set to (Brazilian) Portuguese and Brazilian practice is used where relevant. Different aspects of localization are controlled by individual $LC_-variables ($LC_CTYPE, $LC_COLLATE, $LC_DATE etc.). $LC_ALL can be used to force the same locale for all aspects.
$TZ
Refers to time zone. It can be in several formats, either specifying the timezone itself or referencing a file (in /usr/share/zoneinfo).

DOS

Under DOS the master environment is provided by the primary command processor, which inherits the pre-environment defined in CONFIG.SYS when first loaded. Its size can be configured through the COMMAND /E:n parameter between 160[5] and 32767[5] bytes. Local environment segments inherited to child processes are typically reduced down to the size of the contents they hold. Some command-line processors (like 4DOS) allow to define a minimum amount of free environment space that will be available when launching secondary shells.[5] While the content of environment variables remains unchanged upon storage, their names (without the "%") are always converted to uppercase, with the exception of pre-environment variables defined via the CONFIG.SYS directive SET under DR DOS 6.0 and higher[6] (and only with SWITCHES=/L (for "allow lowercase names") under DR-DOS 7.02 and higher).[5][7] In principle, MS-DOS 7.0 and higher also supports lowercase variable names (%windir%), but provides no means for the user to define them. Environment variable names containing lowercase letters are stored in the environment just like normal environment variables, but remain invisible to most DOS software, since they are written to expect uppercase variables only.[5][6] Some command processors limit the maximum length of a variable name to 80 characters.[5] While principally only limited by the size of the environment segment, some DOS and 16-bit Windows programs do not expect the contents of environment variables to exceed 128 characters. DR-DOS COMMAND.COM supports environment variables up to 255, 4DOS even up to 512 characters.[5] Since COMMAND.COM can be configured (via /L:128..1024) to support command lines up to 1024 characters internally under MS-DOS 7.0 and higher, environment variables should be expected to contain at least 1024 characters as well. In some versions of DR-DOS, the environment passed to drivers, which often do not need their environment after installation, can be shrunken or relocated through SETENV or INSTALL[HIGH]/LOADHIGH options /Z (zero environment), /D[:loaddrive] (substitute drive, e.g. B:TSR.COM) and /E (relocate environment above program) in order to minimize the driver's effectively resulting resident memory footprint.[8][7][6][9][10]

In batch mode, non-existent environment variables are replaced by a zero-length string.

Standard environment variables or reserved environment variables include:

%APPEND% (supported since DOS 3.3)
This variable contains a semicolon-delimited list of directories in which to search for files. It is usually changed via the APPEND /E command, which also ensures that the directory names are converted into uppercase. Some DOS software actually expects the names to be stored in uppercase and the length of the list not to exceed 121[5] characters, therefore the variable is best not modified via the SET command. Long filenames containing spaces or other special characters must not be quoted (").
%CONFIG% (supported since MS-DOS 6.0 and PC DOS 6.1, also supported by ROM-DOS[11])
This variable holds the symbolic name of the currently chosen boot configuration. It is set by the DOS BIOS (IO.SYS, IBMBIO.COM, etc.) to the name defined by the corresponding CONFIG.SYS directive MENUITEM before launching the primary command processor. Its main purpose is to allow further special cases in AUTOEXEC.BAT and similar batchjobs depending on the selected option at boot time. This can be emulated under DR-DOS by utilizing the CONFIG.SYS directive SET like SET CONFIG=1.
%CMDLINE% (introduced with 4DOS, also supported since MS-DOS 7.0)
This variable contains the fully expanded text of the currently executing command line. It can be read by applications to detect the usage of and retrieve long command lines, since the traditional method to retrieve the command line arguments through the PSP (or related API functions) is limited to 126 characters and is no longer available when FCBs get expanded or the default DTA is used. While 4DOS supports longer command lines, COMMAND.COM still only supports a maximum of 126 characters at the prompt by default (unless overridden with /U:128..255 to specify the size of the command line buffer), but nevertheless internal command lines can become longer through f.e. variable expansion (depending on /L:128..1024 to specify the size of the internal buffer). In addition to the command-line length byte in the PSP, the PSP command line is normally limited by ASCII-13, and command lines longer than 126 characters will typically be truncated by having an ASCII-13 inserted at position 127, but this cannot be relied upon in all scenarios. The variable will be suppressed for external commands invoked with a preceding @-symbol like in @XCOPY ... for backward compatibility and in order to minimize the size of the environment when loading non-relocating TSRs. Some beta versions of Microsoft Chicago used %CMDLINE% to store only the remainder of the command line excessing 126 characters instead of the complete command line.[6]
%COMSPEC% (supported since DOS 2.0)
This variable contains the full 8.3 path to the command processor, typically C:\COMMAND.COM or C:\DOS\COMMAND.COM. It must not contain long filenames, but under DR-DOS it may contain file and directory passwords. It is set up by the primary command processor to point to itself (typically reflecting the settings of the CONFIG.SYS directive SHELL), so that the resident portion of the command processor can reload its transient portion from disk after the execution of larger programs. The value can be changed at runtime to reflect changes in the configuration, which would require the command processor to reload itself from other locations. The variable is also used when launching secondary shells.
%COPYCMD% (supported since MS-DOS 6.2 and PC DOS 6.3, also supported by ROM-DOS[11])
Allows a user to specify the /Y switch (to assume "Yes" on queries) as the default for the COPY, XCOPY, and MOVE commands. A default of /Y can be overridden by supplying the /-Y switch on the command line. The /Y switch instructs the command to replace existing files without prompting for confirmation.
%DIRCMD% (supported since MS-DOS 5.0 and PC DOS 5.0, also supported by ROM-DOS[11])
Allows a user to specify customized default parameters for the DIR command, including file specifications. Preset default switches can be overridden by providing the negative switch on the command line. For example, if %DIRCMD% contains the /W switch, then it can be overridden by using DIR /-W at the command line. This is similar to the environment variable %$DIR% under DOS Plus[12] and a facility to define default switches for DIR through its /C or /R switches under DR-DOS COMMAND.COM.[6] %DIRCMD% is also supported by the external SDIR.COM/DIR.COM Stacker commands under Novell DOS 7 and higher.[6]
%LANG% (supported since MS-DOS 7.0)
This variable is supported by some tools to switch the locale for messages in multilingual issues.
%LANGSPEC% (supported since MS-DOS 7.0)
This variable is supported by some tools to switch the locale for messages in multilingual issues.
%NO_SEP% (supported since PC DOS 6.3 and DR-DOS 7.07)
This variable controls the display of thousands-separators in messages of various commands. Issued by default, they can be suppressed by specifying SET NO_SEP=ON or SET NO_SEP=1 under PC DOS. DR-DOS additionally allows to override the system's thousands-separator displayed as in f.e. SET NO_SEP=..[5]
%PATH% (supported since DOS 2.0)
This variable contains a semicolon-delimited list of directories in which the command interpreter will search for executable files. Equivalent to the Unix $PATH variable (but some DOS and Windows applications also use the list to search for data files similar as $LD_LIBRARY_PATH on Unix-like systems). It is usually changed via the PATH (or PATH /E under MS-DOS 6.0) command, which also ensures that the directory names are converted into uppercase. Some DOS software actually expects the names to be stored in uppercase and the length of the list not to exceed 123[5] characters, therefore the variable should better not be modified via the SET command.[5] Long filenames containing spaces or other special characters must not be quoted ("). By default, the current directory is searched first, but some command-line processors like 4DOS allow "." (for "current directory") to be included in the list as well in order to override this search order; some DOS programs are incompatible with this extension.[5]
%PROMPT% (supported since DOS 2.0)
This variable contains a $-tokenized string defining the display of the prompt. It is usually changed via the PROMPT command.
%TEMP% (and %TMP%)
These variables contain the path to the directory where temporary files should be stored. Operating system tools typically only use %TEMP%, whereas third-party programs also use %TMP%. Typically %TEMP% takes precedence over %TMP%.

The DR-DOS family supports a number of additional standard environment variables including:

%BETA%
This variable contains an optional message displayed by some versions (including DR DOS 3.41) of COMMAND.COM at the startup of secondary shells.[13]
%DRDOSCFG%/%NWDOSCFG%/%OPENDOSCFG%
This variable contains the directory[14] (without trailing "\") where to search for .INI and .CFG configuration files (that is, DR-DOS application specific files like TASKMGR.INI, TASKMAX.INI, VIEWMAX.INI, FASTBACK.CFG etc., class specific files like COLORS.INI, or global files like DRDOS.INI, NWDOS.INI, OPENDOS.INI, or DOS.INI), as used by the INSTALL and SETUP commands and various DR-DOS programs like DISKOPT, DOSBOOK, EDIT, FBX, FILELINK, LOCK, SECURITY.OVL/NWLOGIN.EXE, SERNO, TASKMAX, TASKMGR, VIEWMAX, or UNDELETE.[6] It must not contain long filenames.
%DRCOMSPEC%
This variable optionally holds an alternative path to the command processor taking precedence over the path defined in the %COMSPEC% variable, optionally including file and directory passwords. Alternatively, it can hold a special value of "ON" or "1" in order to enforce the usage of the %COMSPEC% variable even in scenarios where the %COMSPEC% variable may point to the wrong command-line processor, for example, when running some versions of the DR-DOS SYS command under a foreign operating system.[15]
%DRSYS%
Setting this variable to "ON" or "1" will force some versions of the DR-DOS SYS command to work under foreign operating systems instead of displaying a warning.[15]
%FBP_USER%
Specifies the user name used by the FastBack command FBX and {user}.FB configuration files under Novell DOS 7.[6]
%HOMEDIR%
This variable may contain the home directory under DR-DOS (including DR DOS 5.0 and 6.0).[6][13]
%INFO%
In some versions of DR-DOS COMMAND.COM this variable defines the string displayed by the $I token of the PROMPT command.[13] It can be used, for example, to inform the user how to exit secondary shells.
%LOGINNAME%
In some versions of DR-DOS COMMAND.COM this variable defines the user name displayed by the $U token of the PROMPT command, as set up by f.e. login scripts for Novell NetWare.[5][6][13] See also the similarly named pseudo-variable %LOGIN_NAME%.
%MDOS_EXEC%
This variable can take the values "ON" or "OFF" under Multiuser DOS. If enabled, the operating system permits applications to shell out to secondary shells with the DOS Program Area (DPA) freed in order to have maximum DOS memory available for secondary applications instead of running them in the same domain as under DOS.[16][17]
%NOCHAR%
This variable can be used to define the character displayed by some commands in messages for "No" in [Y,N] queries, thereby overriding the current system default (typically "N" in English versions of DR-DOS). If it contains a string, only the first character, uppercased, will be taken. Some commands also support a command line parameter /Y to automatically assume "Yes" on queries, thereby suppressing such prompts. If, however, the parameter /Y:yn is used to specify the "Yes"/"No" characters (thereby overriding any %NOCHAR% setting), queries are not suppressed. See also the related CONFIG.SYS directive NOCHAR and the environment variable %YESCHAR%.[15]
%NOSOUND%
Setting this variable to "ON" or "1" will disable default beeps issued by some DR-DOS commands in certain situations such as to inform the user of the completion of some operation, that user interaction is required, or when a wrong key was pressed. Command line options to specifically enable certain beeps will override this setting.
%OS%
This variable contains the name of the operating system in order to distinguish between different DOS-related operating systems of Digital Research-origin in batch jobs and applications.[14] Known values include "DOSPLUS" (DOS Plus 1.2 in DOS emulation), "CPCDOS 4.1" (DOS Plus 1.2 in CP/M emulation), "DRDOS" (DR DOS 3.31-6.0, DR DOS Panther, DR DOS StarTrek, DR-DOS 7.02[14]-7.05), "EZDOS" (EZ-DOS 3.41), "PALMDOS" and "NetWare PalmDOS" (PalmDOS 1.0), "NWDOS" (Novell DOS 7), "NWDOS7" (Novell DOS 7 Beta), "OPENDOS" (Caldera OpenDOS 7.01, Caldera DR-OpenDOS 7.02), "CDOS" (Concurrent DOS, Concurrent DOS XM), "CPCDOS" (Concurrent PC DOS), "CDOS386" (Concurrent DOS 386), "DRMDOS" (DR Multiuser DOS), "MDOS" (CCI Multiuser DOS),[16] "IMSMDOS" (IMS Multiuser DOS), "REAL32" (REAL/32).[6][18] MS-DOS INTERSVR looks for a value of "DRDOS" as well.[18] See also the identically named environment variable %OS% later introduced in the Windows NT family.
%PEXEC%
In some versions of DR-DOS this variable defines the command executed by the $X token of the PROMPT command before COMMAND.COM displays the prompt after returning from external program execution.[6][14]
%SWITCHAR%
This variable defines the SwitChar to be used for argument parsing by some DR-DOS commands. If defined, it overrides the system's current SwitChar setting. The only accepted characters are "/" (DOS style), "-" (Unix style) and "[" (CP/M style). See also the related CONFIG.SYS directive SWITCHAR (to set the system's SwitChar setting) and the %/% system information variable in some issues of DR-DOS COMMAND.COM (to retrieve the current setting for portable batchjobs).
%TASKMGRWINDIR%
This variable specifies the directory, where the Windows SYSTEM.INI to be used by the DR-DOS TASKMGR multitasker is located, overriding the default procedure to locate the file.[6]
%VER%
This variable contains the version of the operating system in order to distinguish between different versions of DR-DOS in batch jobs and in the display of the VER command.[14] It is also used for the $V token of the PROMPT command and affects the value returned by the system information variable %OS_VERSION%. Known values include "1.0" (PalmDOS 1.0), "1.2" (DOS Plus 1.2 in DOS emulation), "2.0" (Concurrent DOS 386 2.0), "3.0" (Concurrent DOS 386 3.0), "3.31" (DR DOS 3.31), "3.32" (DR DOS 3.32), "3.33" (DR DOS 3.33), "3.34" (DR DOS 3.34), "3.35" (DR DOS 3.35), "3.40" (DR DOS 3.40), "3.41" (DR DOS 3.41, EZ-DOS 3.41), "3.41T" (DR DOS 3.41T), "4.1" (Concurrent PC DOS 4.1), "5.0" (DR DOS 5.0, DR Multiuser DOS 5.0), "5.1" (Novell DR Multiuser DOS 5.1), "6.0" (DR Concurrent DOS XM 6.0, DR DOS 6.0), "6.2" (DR Concurrent DOS XM 6.2), "7" (Novell DOS 7, Caldera OpenDOS 7.01, DR-DOS 7.02-7.05), "7.00" (CCI Multiuser DOS 7.00), "7.07" (DR-DOS 7.07), "7.1" (IMS Multiuser DOS 7.1), "7.21" (CCI Multiuser DOS 7.21),[16] "7.22" (CCI Multiuser DOS 7.22) etc.[6][18][16]
%YESCHAR%
This variable can be used to define the character displayed by some commands in messages for "Yes" in [Y,N] queries, thereby overriding the current system default (typically "Y" in English versions of DR-DOS). If it contains a string, only the first character, uppercased, will be taken. Some commands also support a command line parameter /Y to automatically assume "Yes" on queries, thereby suppressing such prompts. If, however, the parameter /Y:y is used to specify the "Yes" character (thereby overriding any %YESCHAR% setting), queries are not suppressed. See also the related CONFIG.SYS directive YESCHAR and the environment variable %NOCHAR%.[15]
%$CLS%
This variable defines the control sequence to be sent to the console driver to clear the screen when the CLS command is issued, thereby overriding the internal default ("←[2J" under DR-DOS, "←E" under DOS Plus 1.2 on Amstrad machines[12] as well as under Concurrent DOS, Multiuser DOS, and REAL/32 for VT52 terminals, or "←+" under Multiuser DOS for ASCII terminals).[16] If the variable is not defined and no ANSI.SYS console driver is detected, the DR-DOS COMMAND.COM will directly clear the screen via INT 10h/AH=00h BIOS function, like MS-DOS/PC DOS COMMAND.COM does. A special \nnn-notation for octal numbers is supported to allow the definition of special characters like ESC (ASCII-27 = "←" = 1Bh = 33o), as f.e. in SET $CLS=\033[2J. To send the backslash ("\") itself, it can be doubled "\\".[6][13][16]
%$DIR%
Supported by DOS Plus accepting the values "L" (long) or "W" (wide) to change the default layout of directory listings with DIR. Can be overridden using the command line options /L or /W.[13][12] See also the similar environment variable %DIRCMD% and the DIR options /C and /R of the DR-DOS COMMAND.COM.[6]
%$PAGE%
Supported by DOS Plus accepting the values "ON" or "OFF" for pagination control. Setting this to "ON" has the same affect as adding /P to commands supporting it (like DIR or TYPE).[13][12]
%$LENGTH%
Used by DOS Plus to define the screen length of the console in lines. This is used to control in a portable way when the screen output should be temporarily halted until a key is pressed in conjunction with the /P option supported by various commands or with automatic pagnination.[13][12] See also the related environment variables %$WIDTH% and %DIRSIZE% as well as the similar pseudo-variable %_ROWS%.
%$WIDTH%
Used by DOS Plus to define the screen width of the console in columns. This is used to control in a portable way the formatting of the screen output of commands like DIR /W or TYPE filename.[13][12] See also the related environment variables %$LENGTH% and %DIRSIZE% as well as the similar pseudo-variable %_COLUMNS%.
%$SLICE%
Used by DOS Plus accepting a numerical value to control the foreground/background time slicing of multitasking programs.[13][12] See also the DOS Plus command SLICE.
%$ON%
This variable can hold an optional control sequence to switch text highlighting, reversion or colorization on. It is used to emphasize or otherwise control the display of the file names in commands like TYPE wildcard, for example SET $ON=\033[1m with ANSI.SYS loaded or SET $ON=\016 for an IBM or ESC/P printer. For the special \nnn octal notation supported, see %$CLS%.[6][12] While the variable is undefined by default under DOS Plus and DR-DOS, the Multiuser DOS default for an ASCII terminal equals SET $ON=\033p.[13][16] See also the related environment variable %$OFF%.
%$OFF%
This variable can hold an optional control sequence to switch text highlighting, reversion or colorization off. It is used to return to the normal output after the display of file names in commands like TYPE wildcard, for example SET $OFF=\033[0m with ANSI.SYS loaded or SET $OFF=\024 for an IBM or ESC/P printer. For the special \nnn octal notation supported, see %$CLS%.[6][12] While the variable is undefined by default under DOS Plus and DR-DOS, the Multiuser DOS default for an ASCII terminal equals SET $OFF=\033q.[13][16] See also the related environment variable %$ON%.
%$HEADER%
This variable can hold an optional control sequence issued before the output of the file contents in commands like TYPE under DR-DOS 7.02 and higher. It can be used for highlighting, pagination or formatting, f.e. when sending the output to a printer, i.e. SET $HEADER=\017 for an IBM or ESC/P printer. For the special \nnn octal notation supported, see %$CLS%.[13] See also the related environment variable %$FOOTER%.
%$FOOTER%
This variable can hold an optional control sequence issued after the output of the file contents in commands like TYPE under DR-DOS 7.02 and higher. It is used to return to the normal output format, i.e. SET $FOOTER=\022\014 in the printer example above. For the special \nnn octal notation supported, see %$CLS%.[13] See also the related environment variable %$HEADER%.

Datalight ROM-DOS supports a number of additional standard environment variables as well including:

%DIRSIZE%
This variable is used to define non-standard screen sizes rows[,cols] for DIR options /P and /W (similar to %$LENGTH% and %$WIDTH% under DOS Plus).[11]
%NEWFILE%
This variable is automatically set to the first parameter given to the CONFIG.SYS directive NEWFILE.[11]

%TZ%, %COMM%, %SOCKETS%, %HTTP_DIR%, %HOSTNAME% and %FTPDIR% are also used by ROM-DOS.[11]

OS/2

%BEGINLIBPATH%
Contains a semicolon-separated list of directories which are searched for DLLs before the directories given by the %LIBPATH% variable (which is set during system startup with the special CONFIG.SYS directive LIBPATH). It is possible to specify relative directories here, including "." for the current working directory. See also the related environment variable %ENDLIBPATH%.
%ENDLIBPATH%
a list of directories to be searched for DLLs like %BEGINLIBPATH%, but searched after the list of directories in %LIBPATH%.

Windows

System path variables refer to locations of critical operating system resources, and as such generally are not user-dependent.

%APPDATA%
Contains the full path to the Application Data directory of the logged-in user. Does not work on Windows NT 4.0 SP6 UK.
%LOCALAPPDATA%
This variable is the temporary files of Applications. Its uses include storing of desktop themes, Windows error reporting, caching and profiles of web browsers.
%ComSpec%/%COMSPEC%
The %ComSpec% variable contains the full path to the command processor; on the Windows NT family of operating systems, this is cmd.exe, while on Windows 9x, %COMSPEC% is COMMAND.COM.
%OS%
The %OS% variable contains a symbolic name of the operating system family to distinguish between differing feature sets in batchjobs. It resembles an identically named environment variable %OS% found in all DOS-related operating systems of Digital Research-origin like Concurrent DOS, Multiuser DOS, REAL/32, DOS Plus, DR DOS, Novell DOS and OpenDOS. %OS% always holds the string "Windows_NT" on the Windows NT family.[19]
%PATH%
This variable contains a semicolon-delimited (do not put spaces in between) list of directories in which the command interpreter will search for an executable file that matches the given command. Environment variables that represent paths may be nested within the %PATH% variable, but only at one level of indirection. If this sub-path environment variable itself contains an environment variable representing a path, %PATH% will not expand properly in the variable substitution. Equivalent to the Unix $PATH variable.
%ProgramFiles%, %ProgramFiles(x86)%, %ProgramW6432%
The %ProgramFiles% variable points to the Program Files directory, which stores all the installed programs of Windows and others. The default on English-language systems is "C:\Program Files". In 64-bit editions of Windows (XP, 2003, Vista), there are also %ProgramFiles(x86)%, which defaults to "C:\Program Files (x86)", and %ProgramW6432%, which defaults to "C:\Program Files". The %ProgramFiles% itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by Windows-on-Windows 64-bit redirection).
%CommonProgramFiles%
This variable points to the Common Files directory. The default is "C:\Program Files\Common Files" in the English version of Windows.
%SystemDrive%
The %SystemDrive% variable is a special system-wide environment variable found on Windows NT and its derivatives. Its value is the drive upon which the system directory was placed. The value of %SystemDrive% is in most cases "C:".
%SystemRoot%
The %SystemRoot% variable is a special system-wide environment variable found on the Windows NT family of operating systems. Its value is the location of the system directory, including the drive and path. The drive is the same as %SystemDrive% and the default path on a clean installation depends upon the version of the operating system. By default:
%windir%
This variable points to the Windows directory. (On the Windows NT family of operating systems, it is identical to the %SystemRoot% variable). Windows 95, Windows 98 and Windows ME are, by default, installed in "C:\Windows". For other versions of Windows, see the %SystemRoot% entry above.

User management variables store information related to resources and settings owned by various user profiles within the system. As a general rule, these variables do not refer to critical system resources or locations that are necessary for the OS to run.

%ALLUSERSPROFILE% (%PROGRAMDATA% since Windows Vista)
This variable expands to the full path to the All Users profile directory. This profile contains resources and settings that are used by all system accounts. Shortcut links copied to the All Users\' Start menu or Desktop directories will appear in every user's Start menu or Desktop, respectively.
%USERDOMAIN%
The name of the Workgroup or Windows Domain to which the current user belongs. The related variable, %LOGONSERVER%, holds the hostname of the server that authenticated the current user's login credentials (name and password). For home PCs and PCs in a workgroup, the authenticating server is usually the PC itself. For PCs in a Windows domain, the authenticating server is a domain controller (a primary domain controller, or PDC, in Windows NT 4-based domains).
%USERPROFILE%
A special system-wide environment variable found on Windows NT and its derivatives. Its value is the location of the current user's profile directory, in which is found that user's HKCU registry hive (NTUSER). Users can also use the %USERNAME% variable to determine the active users login identification.

Optional System variables are not explicitly specified by default but can be used to modify the default behavior of certain built-in console commands. These variables also do not need to be explicitly specified as command line arguments.

Default values

The following tables shows typical default values of certain environment variables under English versions of Windows as they can be retrieved under CMD.

(Some of these variables are also defined when running COMMAND.COM under Windows, but differ in certain important details: Under COMMAND.COM, the names of environment variable are always uppercased. Some, but not all variables contain short 8.3 rather than long filenames. While some variables present in the CMD environment are missing, there are also some variables specific to the COMMAND environment.)

Variable Locale specific Windows XP (CMD) Windows Vista and later (CMD)
%ALLUSERSPROFILE%[20] Yes C:\Documents and Settings\All Users C:\ProgramData[20]
%APPDATA%[20] Yes C:\Documents and Settings\{username}\Application Data C:\Users\{username}\AppData\Roaming[20]
%CommonProgramFiles%[20] Yes C:\Program Files\Common Files C:\Program Files\Common Files[20]
%CommonProgramFiles(x86)%[20] Yes C:\Program Files (x86)\Common Files (only in 64-bit version) C:\Program Files (x86)\Common Files (only in 64-bit version)[20]
%CommonProgramW6432%[20] Yes %CommonProgramW6432% (not supported, not replaced by any value) C:\Program Files\Common Files (only in 64-bit version)[20]
%COMPUTERNAME% No {computername} {computername}
%ComSpec% No C:\Windows\System32\cmd.exe C:\Windows\System32\cmd.exe
%HOMEDRIVE%[20] No C: C:[20]
%HOMEPATH%[20] Yes \Documents and Settings\{username} \Users\{username}[20]
%LOCALAPPDATA%[20] Yes %LOCALAPPDATA% (not supported, not replaced by any value) C:\Users\{username}\AppData\Local[20]
%LOGONSERVER% No \\{domain_logon_server} \\{domain_logon_server}
%PATH% Yes C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths}
%PATHEXT% No .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc
%ProgramData%[20] Yes %ProgramData% (not supported, not replaced by any value) %SystemDrive%\ProgramData[20]
%ProgramFiles%[20] Yes %SystemDrive%\Program Files %SystemDrive%\Program Files[20]
%ProgramFiles(x86)%[20] Yes %SystemDrive%\Program Files (x86) (only in 64-bit version) %SystemDrive%\Program Files (x86) (only in 64-bit version)[20]
%ProgramW6432%[20] Yes %ProgramW6432% (not supported, not replaced by any value) %SystemDrive%\Program Files (only in 64-bit version)[20]
%PROMPT% No Code for current command prompt format, usually $P$G Code for current command prompt format, usually $P$G
%PSModulePath% %PSModulePath% (not supported, not replaced by any value) %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
%PUBLIC%[20] Yes %PUBLIC% (not supported, not replaced by any value) %SystemDrive%\Users\Public[20]
%SystemDrive%[20] No C: C:[20]
%SystemRoot%[20] No The Windows directory, usually C:\Windows, formerly C:\WINNT %SystemDrive%\Windows[20]
%TEMP%[20] and %TMP%[20] Yes %SystemDrive%\Documents and Settings\{username}\Local Settings\Temp %SystemRoot%\TEMP (for system environment variables %TMP% and %TEMP%), %USERPROFILE%\AppData\Local\Temp[20] (for user environment variables %TMP% and %TEMP%)
%USERDOMAIN% No {userdomain} {userdomain}
%USERNAME% No {username} {username}
%USERPROFILE%[20] Yes %SystemDrive%\Documents and Settings\{username} %SystemDrive%\Users\{username}[20]
%windir%[20] No %SystemDrive%\WINDOWS %SystemDrive%\Windows[20]

In this list, there is no environment variable that refers to the location of the user's My Documents directory, so there is no standard method for setting a program's home directory to be the My Documents directory.

Pseudo-environment variables

DOS

Besides true environment variables, which are statically stored in the environment until changed or deleted, a number of pseudo-environment variables exist for batch processing.

The so-called replacement parameters or replaceable parameters (Microsoft / IBM terminology) aka replacement variables (Digital Research / Novell / Caldera terminology)[14] or batch file parameters (JP Software terminology)[5] %1..%9 and %0 can be used to retrieve the calling parameters of a batchjob, see SHIFT. In batchjobs, they can be retrieved just like environment variables, but are not actually stored in the environment.

Some command-line processors (like DR-DOS COMMAND.COM,[14] Multiuser DOS MDOS.COM/TMP.EXE (Terminal Message Process), JP Software 4DOS, 4OS2, 4NT, Take Command and Windows CMD.EXE) support a type of pseudo-environment variables named system information variables (Novell / Caldera terminology)[14] or internal variables (JP Software terminology),[5] which can be used to retrieve various possibly dynamic, but read-only information about the running system in batch jobs. The returned values represent the status of the system in the moment these variables are queried; that is, reading them multiple times in a row may return different values even within the same command; querying them has no direct effect on the system. Since they are not stored in the environment, they are not listed by SET and do not exist for external programs to retrieve. If a true environment variable of the same name is defined, it takes precedence over the corresponding variable until the environment variable is deleted again. They are not case-sensitive. While almost all such variables are prefixed with an underscore ("_") by 4DOS etc. by convention (f.e. %_SECOND%),[5] they are not under DR-DOS COMMAND.COM (f.e. %OS_VERSION%).

In addition, 4DOS, 4OS2, 4NT, and Take Command also support so called variable functions,[5] including user-definable ones. They work just like internal variables, but can take optional parameters (f.e. %@EVAL[]%) and may even change the system status depending on their function.

System information variables supported by DR-DOS COMMAND.COM:

%AM_PM%
This pseudo-variable returns the ante- or post-midday status of the current time. The returned string depends on the locale-specific version of DR-DOS, f.e. "am" or "pm" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
%DAY%
This pseudo-variable returns the days of the current date in a 2-digit format with leading zeros, f.e. "01".."31". See also the similar pseudo-variable %_DAY%. It resembles an identically named identifier variable in Novell NetWare login scripts.
%DAY_OF_WEEK%
This pseudo-variable returns the day name of the week in a 3-character format. The returned string depends on the locale-specific version of DR-DOS, f.e. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", or "Sat" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
%ERRORLEVEL%
In COMMAND.COM of DR-DOS 7.02 and higher, this pseudo-variable returns the last error level returned by an external program or the RETURN command, f.e. "0".."255".[21][22] See also the identically named pseudo-variable %ERRORLEVEL% under Windows and the IF ERRORLEVEL conditional command.
%ERRORLVL%
In DR-DOS 7.02 and higher, this pseudo-variable returns the last error level in a 3-digit format with leading zeros, f.e. "000".."255".[21][22] Under Multiuser DOS, this is a true environment variable automatically updated by the shell to the return code of exiting programs.[16] See also the related pseudo-variable %ERRORLEVEL% under DR-DOS and the IF ERRORLEVEL command.
%GREETING_TIME%
This pseudo-variable returns the 3-level day greeting time. The returned string depends on the locale-specific version of DR-DOS, f.e. "morning", "afternoon", or "evening" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
%HOUR%
This pseudo-variable returns the hours of the current time in 12-hour format without leading zeros, f.e. "1".."12". It resembles an identically named identifier variable in Novell NetWare login scripts.
%HOUR24%
This pseudo-variable returns the hours of the current time in 24-hour format in a 2-digit format with leading zeros, f.e. "00".."23". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_HOUR%.
%MINUTE%
This pseudo-variable returns the minutes of the current time in a 2-digit format with leading zeros, f.e "00".."59". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_MINUTE%.
%MONTH%
This pseudo-variable returns the months of the current date in a 2-digit format with leading zeros, f.e. "01".."12". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_MONTH%.
%MONTH_NAME%
This pseudo-variable returns the month name of the current date. The returned string depends on the locale-specific version of DR-DOS, f.e. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", or "December" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
%NDAY_OF_WEEK%
This pseudo-variable returns the number of day of the current week, f.e. "1".."7" (with "1" for Sunday). It resembles an identically named identifier variable in Novell NetWare login scripts.
%OS_VERSION%
This pseudo-variable returns the version of the operating system depending on the current setting of the environment variable %VER%. If %VER% is not defined, %OS_VERSION% returns "off". It resembles an identically named identifier variable in Novell NetWare login scripts, which may return versions also for non-DR-DOS versions of DOS.
%SECOND%
This pseudo-variable returns the seconds of the current time in a 2-digit format with leading zeros, f.e. "00".."59". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_SECOND%.
%SHORT_YEAR%
This pseudo-variable returns the year of the current date in a 2-digit format with leading zeros, f.e. "93".."99", "00".."92". It resembles an identically named identifier variable in Novell NetWare login scripts.
%YEAR% and %_YEAR%
Supported since Novell DOS 7, the %YEAR% pseudo-variable returns the year of the current date in a 4-digit format, f.e. "1980".."2099". It resembles an identically named identifier variable in Novell NetWare login scripts. DR-DOS 7.02 and higher added %_YEAR% for compatibility with 4DOS, returning the same value.[5]
%/%
In COMMAND.COM of DR-DOS 7.02 and higher, this pseudo-variable returns the current SwitChar setting of the system, either "/" (DOS style) or "-" (Unix style).[23][24] See also the related CONFIG.SYS directive SWITCHAR and the environment variable %SWITCHAR%.
%_CODEPAGE%
This pseudo-variable returns the systems' current code page ("1".."65533"), f.e. "437", "850", "858". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the CHCP command.
%_COLUMNS%
This pseudo-variable returns the current number of screen columns depending on the display mode, f.e. "40", "80", "132", etc. This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also a similar environment variable %$WIDTH% under DOS Plus.
%_COUNTRY%
This pseudo-variable returns the systems' current country code ("1".."65534"), f.e. "1" for USA, "44" for UK, "49" for Germany, "20049" with ISO 8601, "21049" with ISO 8601 and Euro support. This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the CONFIG.SYS directive COUNTRY.
%_DAY%
This pseudo-variable returns the days of the current date without leading zeros, f.e. "1".."31". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %DAY%.
%_HOUR%
This pseudo-variable returns the hours of the current time in 24-hour format without leading zeros, f.e. "0".."23". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %HOUR24%.
%_MINUTE%
This pseudo-variable returns the minutes of the current time without leading zeros, f.e "0".."59". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %MINUTE%.
%_MONTH%
This pseudo-variable returns the months of the current date without leading zeros, f.e. "1".."12". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %MONTH%.
%_ROWS%
This pseudo-variable returns the current number of screen rows depending on the display mode, f.e. "25", "43", "50", etc. This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See a similar environment variable %$LENGTH% under DOS Plus.
%_SECOND%
This pseudo-variable returns the seconds of the current time without leading zeros, f.e. "0".."59". This variable was originally introduced by 4DOS,[5] but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %SECOND%.

System information variables supported by DR-DOS COMMAND.COM with networking loaded:

%LOGIN_NAME%
This pseudo-variable returns the user name. This always worked with NETX, but it will also work with Personal NetWare's ODI/VLM if the current drive is a PNW-mapped drive (otherwise an empty string is returned). See also the similarly named environment variable %LOGINNAME%.
%P_STATION%
This pseudo-variable returns the physical station number in a format "????????????". The value depends on the MAC address of the network adapter, but can be overridden. It resembles an identically named identifier variable in Novell NetWare login scripts.
%STATION%
This pseudo-variable returns the logical station number starting with "1" for the first client. The numbers are assigned by the file server and remain static for as long as the IPX connection remains established. It resembles an identically named identifier variable in Novell NetWare login scripts.
%FULL_NAME%
This pseudo-variable returns the full name of the logged in user, if available. It resembles an identically named identifier variable in Novell NetWare login scripts. See also the related pseudo-variable %LOGIN_NAME%.

Windows

Dynamic environment variables (also named internal variables or system information variables under DOS) are pseudo-environment variables supported by CMD when command-line extensions are enabled, and they expand to various discrete values whenever queried, that is, their values can change when queried multiple times even within the same command. While they can be used in batch jobs and at the prompt, they are not stored in the environment. Consequently, they are neither listed by SET nor do they exist for external programs to read. They are not case-sensitive.

Indirectly, they are also supported under Windows' COMMAND.COM, which has been modified to internally call CMD.EXE to execute the commands.

%CD%
This pseudo-variable expands to the current directory equivalent to the output of the command CD when called without arguments. While a long filename can be returned under CMD.EXE depending on the current directory, the fact that the current directory will always be in 8.3 format under COMMAND.COM will cause it to return a short filename under COMMAND.COM, even when COMMAND internally calls CMD.
%CMDCMDLINE%
This pseudo-variable expands to the original startup parameters of CMD.EXE, f.e. "C:\Windows\system32\cmd.exe". Under Windows' COMMAND.COM, this may return something like "C:\Windows\system32\cmd.exe /c ..." due to the fact that COMMAND.COM calls CMD.EXE internally.
%CMDEXTVERSION%
This pseudo-variable expands to the version of the command-line extensions of CMD.EXE, if enabled (e.g. "1" under Windows NT, "2" under Windows 2000 and Windows XP).
%DATE%
This pseudo-variable expands to the current date. The date is displayed according to the current user's date format preferences.
%ERRORLEVEL%
This pseudo-variable expands to the last set error level, a value between "0" and "255" (without leading zeros).[21][25][22] External commands and some internal commands set error levels upon execution. See also the identically named pseudo-variable %ERRORLEVEL% under DR-DOS and the IF ERRORLEVEL command.
%RANDOM%
This pseudo-variable returns a random number between "0" and "32767".
%TIME%
This pseudo-variable returns the current time. The time is displayed according to the current user's time format preferences. If the %TIME% and %DATE% variables are both used, it is important to read them both in this particular order in rapid succession in order to avoid midnight-rollover problems.

See also

References

  1. ^ Robbins, Arnold; Beebe, Nelson H.F. (May 2005). Apandi, Tatiana; Randal, Allison; Witwer, Adam, eds. Classic Shell Scripting (1st ed.). O'Reilly. ISBN 978-0-596-00595-5.CS1 maint: Uses editors parameter (link)
  2. ^ "unset - unset values and attributes of variables and functions – ". Commands & Utilities Reference, The Single UNIX Specification - The Open Group Base Specifications, IEEE Std 1003.1-2008 (Issue 7 ed.). The IEEE and The Open Group. 2016 [2001]. Archived from the original on 2017-12-18. Retrieved 2017-12-18.
  3. ^ fgrose (2015-07-31) [2011]. "The unset builtin command". Bash Hackers Wiki. Archived from the original on 2017-12-18. Retrieved 2017-12-18.
  4. ^ Jacobs, Mike; Koren, Alexander; Satran, Michael (2017-11-14). "Store and retrieve settings and other app data". Microsoft. Archived from the original on 2017-12-18. Retrieved 2017-12-18.
  5. ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa Brothers, Hardin; Rawson, Tom; Conn, Rex C.; Paul, Matthias; Dye, Charles E.; Georgiev, Luchezar I. (2002-02-27). 4DOS 8.00 online help.
  6. ^ a b c d e f g h i j k l m n o p q r Paul, Matthias (1997-07-30). NWDOS-TIPs — Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds (e-book). MPDOSTIP (in German) (3, release 157 ed.). Archived from the original on 2016-11-04. Retrieved 2014-08-06. (NB. NWDOSTIP.TXT is a comprehensive work on Novell DOS 7 and OpenDOS 7.01, including the description of many undocumented features and internals. It is part of the author's yet larger MPDOSTIP.ZIP collection maintained up to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the NWDOSTIP.TXT file.)
  7. ^ a b Paul, Matthias (1997-10-02). "Caldera OpenDOS 7.01/7.02 Update Alpha 3 IBMBIO.COM README.TXT". Archived from the original on 2003-10-04. Retrieved 2009-03-29. [1]
  8. ^ Paul, Matthias (1997-05-27) [1996]. "SETENV v1.11". Archived from the original on 2009-02-15. […] SETENV […] to hide and later restore the […] pre-environment […] By using SETENV.COM you can save some KiloBytes of rare DOS memory […] depending on the number of drivers loaded by INSTALL=/INSTALLHIGH=/HIINSTALL= and the current size of the pre-environment. […] this original […] feature cannot be found in any known memory manager/optimizer. […]
  9. ^ "PTS-DOS 2000 Pro User Manual" (PDF). Archived (PDF) from the original on 2018-05-12. Retrieved 2018-05-12.
  10. ^ Paul, Matthias (2002-10-07). "Re: Run a COM file". alt.msdos.programmer. Archived from the original on 2017-09-03. Retrieved 2017-09-03. [2]
  11. ^ a b c d e f Datalight, Inc.; GPvNO (April 2005) [1999]. "Datalight ROM-DOS User's Guide" (PDF). Datalight, Inc. 3010-0200-0716. Retrieved 2018-09-16.
  12. ^ a b c d e f g h i Kotulla, Martin (November 1987). "Von CP/M zu MS-DOS, Teil 11" (PDF). Professional Computing (PC) - Schneider International (in German). 3 (11): 100–103. Retrieved 2018-05-20.
  13. ^ a b c d e f g h i j k l m n Paul, Matthias (2002-03-26). "Updated CLS posted". freedos-dev mailing list. Retrieved 2014-08-06.
  14. ^ a b c d e f g h DR-DOS 7.02 User Guide. Caldera, Inc. 1998. Archived from the original on 2016-11-04. Retrieved 2013-08-10.
  15. ^ a b c d Paul, Matthias (2017-08-14) [2017-08-07]. "The continuing saga of Windows 3.1 in enhanced mode on OmniBook 300". MoHPC - the Museum of HP Calculators. Archived from the original on 2018-05-01. Retrieved 2018-05-01. […] set DRSYS=ON (optional to tell SYS you are aware of the fact that you're running it in a foreign environment and want to proceed anyway without having to individually ACK some warnings and extra info screens displayed in this scenario otherwise) […]
  16. ^ a b c d e f g h i CCI Multiuser DOS 7.22 GOLD Online Documentation. Concurrent Controls, Inc. (CCI). 1997-02-10. HELP.HLP.
  17. ^ CCI Multiuser DOS 7.22 GOLD Installation Guide. Concurrent Controls, Inc. (CCI). 1997-02-10. PRINTDOC.HLP.
  18. ^ a b c Paul, Matthias (2002-02-20). "How to detect FreeCOM/FreeDOS in-batch?". freedos-dev mailing list. Retrieved 2014-08-06.
  19. ^ https://www.tenforums.com/tutorials/3234-environment-variables-windows-10-a.html
  20. ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak Schulz, Hajo (2014-10-02). "Ordner für spezielle Fälle — Die "benannten Ordner" in Windows aus User- und Entwicklersicht" [Special purpose folders — Windows' "named folders" from a user's and developer's perspective]. c't - magazin für computertechnik (in German). Heise Verlag. 2014 (22): 180–184.
  21. ^ a b c Paul, Matthias (1997-05-01) [1993]. BATTIPs — Tips & Tricks zur Programmierung von Batchjobs. MPDOSTIP (in German). 7: ERRORLEVEL abfragen. Archived from the original on 2017-08-23. Retrieved 2017-08-23. [3] [4] (NB. BATTIPS.TXT is part of MPDOSTIP.ZIP. The provided link points to a HTML-converted older version of the BATTIPS.TXT file.)
  22. ^ a b c Auer, Eric; Paul, Matthias; Hall, Jim (2015-12-24) [2003-12-31]. "MS-DOS errorlevels". Archived from the original on 2015-12-24.
  23. ^ Paul, Matthias (1998-01-09). DELTREE.BAT R1.01 Extended file and directory delete. Caldera, Inc.
  24. ^ DR-DOS 7.03 WHATSNEW.TXT — Changes from DR-DOS 7.02 to DR-DOS 7.03. Caldera, Inc. 1998-12-24.
  25. ^ Allen, William; Allen, Linda. "Windows 95/98/ME ERRORLEVELs". Archived from the original on 2005-10-29.

Further reading

External links

Authbind

authbind is an Open-source system utility written by Ian Jackson and is distributed under the GNU General Public License. The authbind software allows a program that would normally require superuser privileges to access privileged network services to run as a non-privileged user. authbind allows the system administrator to permit specific users and groups access to bind to TCP and UDP ports below 1024. Ports 0 - 1023 are normally privileged and reserved for programs that are run as the root user. Allowing regular users limited access to privileged ports helps prevent possible privilege escalation and system compromise if the software happens to contain software bugs or is found to be vulnerable to unknown exploits.

authbind achieves this by defining the LD_PRELOAD environment variable which loads a libauthbind library. This library overrides the bind() call with a version that executes a setuid helper program (/usr/lib/authbind/helper) with the socket as file descriptor 0. The helper validates its arguments and checks its configuration, calls the real bind() system call on file descriptor 0 (which also affects the original process's socket), and exits, allowing the original process to continue with the socket bound to the requested address and port.

authbind is currently distributed with the Debian and Ubuntu Linux distributions.

COMMAND.COM

COMMAND.COM is the default command-line interpreter for DOS, Windows 95, Windows 98 and Windows ME. In the case of DOS, it is the default user interface as well. It has an additional role as the first program run after boot, hence being responsible for setting up the system by running the AUTOEXEC.BAT configuration file, and being the ancestor of all processes. COMMAND.COM's successor on OS/2 and Windows NT systems is cmd.exe, although COMMAND.COM is available on IA-32 versions of those operating systems.

COMMAND.COM is a DOS program. Programs launched from COMMAND.COM are DOS programs that use the DOS API to communicate with the operating system (DOS).

COMSPEC

COMSPEC or ComSpec is one of the environment variables used in DOS, OS/2 and Windows, which normally points to the command line interpreter, which is by default COMMAND.COM in DOS or CMD.EXE in OS/2 and Windows NT. The variable name is written in all-uppercase under DOS and OS/2. Under Windows, which also supports lowercase environment variable names, the variable name is COMSPEC inside the DOS emulator NTVDM and for any DOS programs, and ComSpec under CMD.EXE.

The variable's contents can be displayed by typing SET or ECHO %COMSPEC% at the command prompt.

The environment variable by default points to the full path of the command line interpreter. It can also be made by a different company or be a different version.

Classpath (Java)

Classpath is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable.

Clobbering

In software engineering, clobbering a file or computer memory is overwriting its contents. The Jargon File defines clobbering as

To overwrite, usually unintentionally: "I walked off the end of the array and clobbered the stack." Compare mung, scribble, trash, and smash the stack.

Often this happens unintentionally, such as using the > redirection operator. To prevent unintentional clobbering, various means are used. For example, the setting shell parameter set -o noclobber (bash, ksh) or set noclobber (csh, tcsh) will prevent > from clobbering by making it issue an error message instead:

The default behavior of the mv and cp commands is to clobber their destination file if it already exists. This behavior may be overridden by invoking or aliasing the commands with the -i switch, causing the commands to prompt the user before overwriting the destination file.

In makefiles, a common target clobber means complete cleanup of all unnecessary files and directories produced by previous invocations of the make command. It is a more severe target than clean and is commonly used to uninstall software. Some make-related commands invoke "make clobber" during their execution. They check the CLOBBER environment variable. If it is set to OFF then clobbering is not done.In assembler programming, the term 'clobbered registers' is used to denote any registers whose value may be overwritten during the course of executing an instruction or procedure.

CoSign single sign on

Cosign is an open-source project originally designed by the Research Systems Unix Group to provide the University of Michigan with a secure single sign-on web authentication system.

Cosign authenticates a user on the web server and then provides an environment variable for the user's name. When the user accesses a part of the site that requires authentication, the presence of that variable allows access without having to sign on again.

Cosign is part of the National Science Foundation Middleware Initiative (NMI) EDIT software release.

Exec (system call)

In computing, exec is a functionality of an operating system that runs an executable file in the context of an already existing process, replacing the previous executable. This act is also referred to as an overlay. It is especially important in Unix-like systems, although other operating systems implement it as well. Since a new process is not created, the original process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program.

The exec call is supported in many programming languages, including compilable languages and some scripting languages. In OS command interpreters, the exec built-in command replaces the shell process with the specified program.

GNU Core Utilities

The GNU Core Utilities or coreutils is a package of GNU software containing reimplementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.

In September 2002, the GNU coreutils were created by merging the earlier packages textutils, shellutils, and fileutils, along with some other miscellaneous utilities. In July 2007, the license of the GNU coreutils was updated from GPLv2 to GPLv3.The GNU core utilities support long options as parameters to the commands, as well as the relaxed convention allowing options even after the regular arguments (unless the POSIXLY_CORRECT environment variable is set). Note that this environment variable enables a different functionality in BSD.

See the List of GNU Core Utilities commands for a brief description of included commands.

Alternative implementation packages are available in the FOSS ecosystem, with a slightly different scope and focus, or license. For example, GPLv2-licensed BusyBox and BSD-licensed Toybox are available for use in embedded devices.

Java Classloader

The Java Class Loader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine. Usually classes are only loaded on demand. The Java run time system does not need to know about files and file systems because of classloaders. Delegation is an important concept to understand when learning about classloaders.

A software library is a collection of related object code.

In the Java language, libraries are typically packaged in JAR files. Libraries can contain objects of different types. The most important type of object contained in a Jar file is a Java class. A class can be thought of as a named unit of code. The class loader is responsible for locating libraries, reading their contents, and loading the classes contained within the libraries. This loading is typically done "on demand", in that it does not occur until the class is called by the program. A class with a given name can only be loaded once by a given classloader.

Each Java class must be loaded by a class loader. Furthermore, Java programs may make use of external libraries (that is, libraries written and provided by someone other than the author of the program) or they may be composed, at least in part, of a number of libraries.

When the JVM is started, three class loaders are used:

Bootstrap class loader

Extensions class loader

System class loaderThe bootstrap class loader loads the core Java libraries located in the /jre/lib directory. This class loader, which is part of the core JVM, is written in native code.

The extensions class loader loads the code in the extensions directories (/jre/lib/ext, or any other directory specified

by the java.ext.dirs system property). It is implemented by the sun.misc.Launcher$ExtClassLoader class.

The system class loader loads code found on java.class.path, which maps to the CLASSPATH environment variable. This is implemented by the sun.misc.Launcher$AppClassLoader class.

More (command)

In computing, more is a command to view (but not modify) the contents of a text file one screen at a time.

It is available on Unix and Unix-like systems, DOS, FlexOS, 4690 OS, OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.

PATH (variable)

PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.

Portable application

A portable application (portable app), sometimes also called standalone, is a program designed to read and write its configuration settings into an accessible folder in the computer, usually the folder where the portable application can be found. This makes it easier to transfer the program with the user's preferences and data between different computers. A program that doesn't have any configuration options is also a portable application.

Portable applications can be stored on any data storage device, including internal mass storage, a file share, cloud storage or external storage such as USB drives and floppy disks—storing its program files and any configuration information and data on the storage medium alone. If no configuration information is required a portable program can be run from read-only storage such as CD-ROMs and DVD-ROMs. Some applications are available in both installable and portable versions.

Some applications which are not portable by default do support optional portability through other mechanisms, the most common being command-line arguments. Examples might include /portable to simply instruct the program to behave as a portable program, or --cfg=/path/inifile to specify the configuration file location.

Like any application, portable applications must be compatible with the computer system hardware and operating system.

Depending on the operating system, portability is more or less complex to implement; to operating systems such as AmigaOS, all applications are by definition portable.

Reaction norm

In ecology and genetics, a reaction norm, also called a norm of reaction, describes the pattern of phenotypic expression of a single genotype across a range of environments. One use of reaction norms is in describing how different species—especially related species—respond to varying environments. But differing genotypes within a single species may also show differing reaction norms relative to a particular phenotypic trait and environment variable. For every genotype, phenotypic trait, and environmental variable, a different reaction norm can exist; in other words, an enormous complexity can exist in the interrelationships between genetic and environmental factors in determining traits. The concept was introduced by Richard Woltereck.

Shellshock (software bug)

Shellshock, also known as Bashdoor, is a family of security bugs in the widely used Unix Bash shell, the first of which was disclosed on 24 September 2014. Many Internet-facing services, such as some web server deployments, use Bash to process certain requests, allowing an attacker to cause vulnerable versions of Bash to execute arbitrary commands. This can allow an attacker to gain unauthorized access to a computer system.Stéphane Chazelas contacted Bash's maintainer, Chet Ramey, on 12 September 2014 telling Ramey about his discovery of the original bug, which he called "Bashdoor". Working together with security experts, he soon had a patch as well. The bug was assigned the identifier CVE-2014-6271. It was announced to the public on 24 September 2014 when Bash updates with the fix were ready for distribution.The first bug causes Bash to unintentionally execute commands when the commands are concatenated to the end of function definitions stored in the values of environment variables. Within days of the publication of this, intense scrutiny of the underlying design flaws discovered a variety of related vulnerabilities (CVE-2014-6277, CVE-2014-6278, CVE-2014-7169, CVE-2014-7186 and CVE-2014-7187); which Ramey addressed with a series of further patches.Attackers exploited Shellshock within hours of the initial disclosure by creating botnets of compromised computers to perform distributed denial-of-service attacks and vulnerability scanning. Security companies recorded millions of attacks and probes related to the bug in the days following the disclosure.Shellshock could potentially compromise millions of unpatched servers and other systems. Accordingly, it has been compared to the Heartbleed bug in its severity.

Temporary Internet Files

Temporary Internet Files is a folder on Microsoft Windows which serves as the browser cache for Internet Explorer to cache pages and other multimedia content, such as video and audio files, from websites visited by the user. This allows such websites to load more quickly the next time they are visited.

Temporary folder

In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals, leaving the directory itself intact.

For security reasons, it is best for each user to have their own temporary directory, since there has been a history of security vulnerabilities with temporary files due to programs incorrect file permissions or race conditions.

A standard procedure for system administration is to reduce the amount of storage space used (typically, on a disk drive) by removing temporary files. In multi-user systems, this can potentially remove active files, disrupting users' activities. To avoid this, some space-reclaiming procedures remove only files which are inactive or "old" - those which have not been read or modified in several days.

Terminal (macOS)

Terminal (Terminal.app) is the terminal emulator included in the macOS operating system by Apple. Terminal originated in NeXTSTEP and OPENSTEP, the predecessor operating systems of macOS.As a terminal emulator, the application provides text-based access to the operating system, in contrast to the mostly graphical nature of the user experience of macOS, by providing a command line interface to the operating system when used in conjunction with a Unix shell, such as bash (the default shell in Mac OS X Jaguar and later). The user can choose other shells available with macOS, such as the Korn shell, tcsh, and zsh.The preferences dialog for Terminal.app in OS X 10.8 (Mountain Lion) and later offers choices for values of the TERM environment variable. Available options are ansi, dtterm, nsterm, rxvt, vt52, vt100, vt102, xterm, xterm-16color and xterm-256color, which differ from the OS X 10.5 (Leopard) choices by dropping the xterm-color and adding xterm-16color and xterm-256color. These settings do not alter the operation of Terminal, and the xterm settings do not match the behavior of xterm.Terminal includes several features that specifically access macOS APIs and features. These include the ability to use the standard macOS Help search function to find manual pages and integration with Spotlight. Terminal was used by Apple as a showcase for macOS graphics APIs in early advertising of Mac OS X, offering a range of custom font and coloring options, including transparent backgrounds.

Title (command)

In computing, title is a command in various command line interpreters (shells) such as the Windows Command Prompt, the Command Processor Shell of Windows Embedded CE and Take Command that changes the title for the graphical terminal emulator window.

The command is also used within DFS and ADFS to change the title of the disc in the current drive.In case of the Windows Command Prompt it is a shell builtin of the command line interpreter cmd.exe.

The default window title is defined in the %COMSPEC% environment variable. However, since the Win32 console title can also be defined in the program shortcut, the title is usually set to "Command Prompt".

The command is available in Windows 2000 and later.Although the OS/2 command shell is closely related to the Windows Command Prompt, the title command is not available in the OS/2 version of cmd.exe. The default title of the OS/2 shell window is "OS/2 Window". It can be changed using the start command.

The ReactOS Command Prompt also includes the title command to set the window title for the command prompt window.

The command also is not available in the Mac OS X Terminal. Instead, the echo command can be used in combination with special escape sequences.Within the GNU GRUB command processor title is one of several menu-specific commands. It is used to start a new boot entry.

X Window authorization

In the X Window System, programs run as X clients, and as such they connect to the X display server, possibly via a computer network. Since the network may be accessible to other users, a method for forbidding access to programs run by users different from the one who is logged in is necessary.

There are five standard access control mechanisms that control whether a client application can connect to an X display server. They can be grouped in three categories:

access based on host

access based on cookie

access based on userAdditionally, like every other network connection, tunneling can be used.

This page is based on a Wikipedia article written by authors (here).
Text is available under the CC BY-SA 3.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.