Programming Field

Path - DOS/Command Prompt Reference

The environment variable ‘PATH’ contains the directory paths to search for programs without a directory path when executing the programs. The command ‘Path’ is available to change the value of ‘PATH’ variable.

Syntax

PATH
PATH=<path-list>
PATH <path-list>
set PATH=[<path-list>]
<path-list>

Specifies a directory to search for programs. To specify multiple directories, separates the directories with semicolons ‘;’. You can use environment variables with ‘%’ characters or omit <path-list> (to set Path to empty) only when using Set.

If not using Set, and omitting <path-list>, the current value of Path will be displayed.

[Windows 95/98/Me] To use the long path name, enclose its path with double quotations ‘" "’.

[Windows NT?/2000?/XP or later] Since environment variables are expanded without using Set, you can use environment variables in the second syntax.

Details

Usage of Path

Path is used to search for programs by the system. For example, when executing ‘notepad.exe’ with Path value ‘C:\Dos;C:\Windows’, the system uses Path value and searches for ‘notepad.exe’ from ‘C:\Dos’ and ‘C:\Windows’ in order. The system searches from the first directory in order when multiple directories are in Path variable, so if you want to prioritize a particular directory, please specify it earlier in the list.

If changing Path in the Windows prompt, its change will only affect to the prompt. To apply the change to OS-wide, write PATH setting into Autoexec.bat (in Windows 95/98/Me), or change ‘environment variables’ in Advanced system settings or use Setx program (in Windows NT/2000/XP or later).

Samples

Sample 1

set PATH=C:\DOS;%windir%;C:\usr\bin

Sets the value to Path, and let the system search for programs from ‘C:\DOS’, ‘%windir%’ (expanded when setting), and ‘c:\usr\bin’ in order when executing programs.

[Windows NT?/2000?/XP or later] This statement is equal to the statement below.

PATH=C:\DOS;%windir%;C:\usr\bin

Sample 2

set PATH=%PATH%;C:\MyDir

Adds ‘C:\MyDir’ to Path.

[Windows NT?/2000?/XP or later] This statement is equal to the statement below.

Path=%PATH%;C:\MyDir

Sample 3

PATH

Displays the current Path value. Since Path is one of the environment variables, the value can also be displayed by using Echo as follows.

echo %PATH%