PATH

Display or set a search path for executable files

Syntax
      PATH pathname [;pathname] [;pathname] [;pathname]...
      PATH
      PATH ;

Key
   pathname : drive letter and/or folder
    ;       : the command 'PATH ;' will clear the path

PATH without parameters will display the current path.

The %PATH% environment variable contains a list of folders. When a command is issued at the CMD prompt, the operating system will first look for an executable file in the current folder, if not found it will scan %PATH% to find it.

Use the PATH command to display or change the list of folders stored in the %PATH% environment variable.

It is important that the pathnames are delimited with semicolons NOT by quotes.
PowerShell in particular will ignore any path node delimited by double quotes.

To view each item on a single line use this:

for %G in ("%path:;=" "%") do @echo %G

Or in a batch file:

for %%G in ("%path:;=" "%") do @echo %%G

To add items to the current path, include %PATH% in your new setting.
For Example:

PATH=%PATH%;C:\Program Files\My Application

Note you do not need to surround each part of the path with double quotes, PATH will always treat spaces as part of the filename.

Permanent Changes

Changes made using the PATH command are NOT permanent, they apply to the current CMD prompt only and remain only until the CMD window is closed.

To permanently change the PATH use

Control Panel, System, Environment, System Variables
Control Panel, System, Environment, User Variables

The %PATH% variable is set as both a system and user variable, the 2 values are combined to give the PATH for the currently logged in user. This is explained in full by MS Product Support Article Q100843

Be wary of using commands like SETX to modify the PATH - the User path can be edited, but the System path remains read-only for most users. If you try to delete an old value and add a new one it is very common for the 'delete' to fail and the 'add' to succeed, resulting in duplicate values being added to the path.

If you are trying to modify the path to add settings for a single application, a reasonably safe method is to use a second variable:
e.g.

SetX MYAPP "C:\Program Files\My App" -m

Now include your new variable in the path like so ...C:\Windows\system32;%MYAPP%

You can now easily change that one variable %MYAPP% at any time in the future and the PATH will reflect the new value.

Dpath

DPATH is an undocumented internal utility that allows the TYPE command to read data files in specified directories as if they were in in the current directory. On some OS's this is also implemented as the now deprecated APPEND command. The list of directories is held in the %DPATH% environment variable which works just like the %PATH% variable, delimited with semicolons (not quotes). Syntax: DPATH pathname [;pathname]...

To type any file on the path:

C:\batch\> type win.ini
The system cannot find the file specified.
C:\batch\> dpath %path%
C:\batch\> type win.ini

Terminology

For a file stored as:
C:\Program Files\Adobe\Acrobat.exe

The Drive is:
C:

The Filename is:
Acrobat.exe

The Path is:
\Program Files\Adobe\

The Full Drive/Pathname is
C:\Program Files\Adobe\Acrobat.exe

PATH is an internal command.

“If you do not love your job, change it. Instead of pushing paper, push ideas. Instead of sitting down, stand up and be heard. Instead of complaining, contribute. don’t get stuck in a job description” - Microsoft job advert

Related:

SET - Display, set, or remove environment variables.
PATHMAN - Resource Kit utility - modify system and user paths. Pathman can resolve duplicate characters, and can improve performance by removing duplicate paths. For details see Pathman.wri in the resource kit.
DLL Search order - SafeDllSearchMode (Win XP)
Fix Path - Bill Stewart's path utility
Powershell: DIR Env: or "$Env:path"
Path (computing) - Wikipedia
Equivalent bash command (Linux): env - Display, set, or remove environment variables - PATH/CDPATH/MAILPATH


© Copyright SS64.com 1999-2014
Some rights reserved