Environment variablessuggest change
The environment variables of the command interpreter process are inherited by the processes of any (external) commands that it executes. A few environment variables are used by the command interpreter itself. Changing them changes its operation.
Environment variables are affected by the SET, PATH, and PROMPT commands.
To unset a variable, set it to empty string, such as
The command interpreter inherits its initial set of environment variables from the process that created it. In the case of command interpreters invoked from desktop shortcuts this will be Windows Explorer, for example.
Command interpreters generally have textual user interfaces, not graphical ones, and so do not recognize the Windows message that informs applications that the environment variable template in the Registry has been changed. Changing the environment variables in Control Panel will cause Windows Explorer to update its own environment variables from the template in the Registry, and thus change the environment variables that any subsequently invoked command interpreters will inherit. However, it will not cause command interpreters that are already running to update their environment variables from the template in the Registry.
COMSPEC environment variable contains the full path name of the command interpreter program file. This is just inherited from the parent process, and is thus indirectly derived from the setting of
COMSPEC in the environment variable template in the Registry.
The value of the
PATH environment variable comprises a list of directory names, separated by semi-colon characters. This is the list of directories that are searched, in order, when locating the program file of an external command to execute.
The value of the
PATHEXT environment variable comprises a list of filename extensions, separated by semi-colon characters. This is the list of filename extensions that are applied, in order, when locating the program file of an external command to execute.
An example content of
PATHEXT printed by
By adding ".PL" to the variable, you can ensure Perl programs get run from the command line even when typed without the ".pl" extension. Thus, instead of typing "mydiff.pl a.txt b.txt", you can type "mydiff a.txt b.txt".
Adding ".PL" to the variable in Windows Vista and later:
setx PATHEXT %PATHEXT%;.PL
- If you use "set" available in Windows XP, the effect will be temporary and impacting only the current console or process.
- Windows Environment Variables at ss64
- Making Python scripts run on Windows without specifying “.py” extension at stackoverflow
PROMPT environment variable controls the text emitted when the command interpreter displays the prompt. The command interpreter displays the prompt when prompting for a new command line in interactive mode, or when echoing a batch file line in batch file mode.
Various special character sequences in the value of the
PROMPT environment variable cause various special effects when the prompt is displayed, as in the following table:
|$$||$ character itself|
|$A||& symbol AKA ampersand. A convenience, since it is difficult to place a literal & in the value of the PROMPT environment variable using the SET command.|
|$B||Vertical bar '|' (pipe symbol)|
|$C||Left parenthesis '('|
|$E||ESC (ASCII code 27)|
|$F||Right parenthesis ')'|
|$G||Greater-than symbol '>'|
|$H||Backspace (deletes previous character)|
|$L||Less-than symbol '<'|
|$M||Remote name linked to the current drive if it is a network drive; empty string otherwise.|
|$N||Current drive letter|
|$P||Current drive letter and full path|
|$Q||'=' (equals sign)|
|$S||' ' (space character)|
|$T||Current system time|
|$V||Windows version number|
|$_||<CR> (carriage return character, aka "enter")|
|$+||As many plus signs (+) as there are items on the pushd directory stack|