Home > Commands N-Z > Commands P

PATH


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Indicates which directories the operating system should search for executable files.

The operating system uses the PATH command to search for executable files in the directories you specify in the %PATH% environment variable. By default, the search path is the current directory only.


Syntax

PATH /?

PATH [[%PATH%] [drive:]path[;...]]

or

PATH=[[%PATH%] [drive:]path[;...]]

Display current search path:

PATH

Clear all search-path settings other than the default setting (the current directory):

PATH ;


Parameters
drive: ( path v2.0 Win95 NT3.1)
Specifies a drive, directory, and any subdirectories to search.
%PATH% (NT2000)
Appends the command path to the existing set of directories listed in the %PATH% environment variable.
; (v2.0 Win95 NT3.1)
When used as the only parameter, clears all search-path settings and specifies that the operating system is to search only the current directory.

Switches
/? (NTXP)
Displays help.

Related

For information about setting a search path for data files, see the APPEND command.
SET - Display, set, or remove environment variables.
PATHMAN - This Resource Kit utility allows quick modification of both the system and user paths. Pathman can resolve many problems such as duplicate characters, and can improve performance by removing duplicate paths. For details see Pathman.wri in the resource kit.
Equivalent Linux BASH commands:
env - Display, set, or remove environment variables.
CDPATH - Environment variable.
MAILPATH - Environment variable.
PATH - Environment variable.


Notes
Current directory searched first

The operating system always searches in the current directory first, before it searches directories in the search path.


Length limit for the PATH command

The maximum length of the PATH command is 127 characters. To fit more directories in the search path, you can shorten directory names, use the SUBST redirect directories to logical drives (which shortens the entries on the PATH command-line), or use the APPEND /X:ON command.

v6.0 and v6.2: PATH Not Limited to 128 Characters. For more information, see Microsoft Q97


Files with the same name, different extensions

You might have some files in the same directory that share the same filename but have different extensions. For example, you might have a file named ACCNT.COM that starts an accounting program and another file named ACCNT.BAT that connects your system to the accounting system network.

The operating system searches for a file by using default filename extensions in the order of precedence: .COM, .EXE, and .BAT. To run ACCNT.BAT when ACCNT.COM exists in the same directory, you must include the .BAT extension on the command-line.


Two or more identical filenames in the PATH

You might have two or more files in the search path that have the same filename and extension. The operating system searches for the specified filename first in the current directory. Then it searches directories in the order in which they are listed in the PATH command.


Specifying multiple directories in PATH command

To specify more than one path for the operating system to search, separate entries with a semicolon (;).


Using PATH in your AUTOEXEC.BAT file

If you place the PATH command in your AUTOEXEC.BAT file, the operating system automatically initiates the specified search path every time you start your computer.


Examples

This command specifies that the operating system is to search three directories to find commands (the three paths for these directories are C:\USER\TAXES, B:\USER\INVEST, and B:\BIN):

    PATH C:\USER\TAXES;B:\USER\INVEST;B:\BIN

A batch example. Specifies that the operating system is to search in the order: folder_3 + folder_2 + folder_1 + same as above.

    PATH C:\USER\TAXES;B:\USER\INVEST;B:\BIN
    SET path=..\;..\..\;%PATH%
    CD \FOLDER_1\FOLDER_2\FOLDER_3

Errorlevels

none.


Availability
Internal
DOS
v2.0 v2.01 v2.05 v2.10 v2.11 v2.11R v2.12 v2.2 v2.25 v3.0 v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10 v8.00
Windows
Win95 Win98 WinME
Windows NT
NT3.1 NT3.5 NT3.51 NT4 NT2000 NTXP NT2003

Last Updated: 2006/12/01
Direct corrections or suggestions to: Rick Lively