fortypoundhead.com

PATH

Posted On 2006-11-27 by FortyPoundHead
Keywords: Command Reference PATH
Tags: Windows Commandline Tutorial Windows
Views: 1491


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 pathPATH 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.

To view each item on a single line use this batch script:

::viewpath.cmd
@echo off
::echo the path one line at a time
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

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.

T o permanently change the PATH use

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

You can also do this at the command line with SETX

Changing a variable in the Control Panel will not affect any CMD prompt that is already open.
Only new CMD prompts will get the new setting.

To change a system variable you must have administrator rights

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

If your system has an AUTOEXEC.BAT file then any PATH setting in AUTOEXEC.BAT will also be appended to the %PATH% environment variable. This is to provide compatibility with old installation routines which need to set the PATH. All other commands in AUTOEXEC.BAT are ignored.

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 Pathname is:
\Program Files\Adobe\Acrobat.exe

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


About the Author

FortyPoundHead has posted a total of 1974 articles.

 


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.161.79.96

Before you can post, you need to prove you are human. If you log in, this test goes away.



Recent Forum Posts

SSL Now Active
dwirch posted on June 16, 2017 at about 8:40 in Site News

SSL Now Active
dwirch posted on June 13, 2017 at about 7:59 in Site News

Coding Archive?
dwirch posted on June 3, 2017 at about 12:54 in Site News

Job Spammer: Bharti Jigyasi
dwirch posted on June 2, 2017 at about 16:57 in Spammers

Coding Archive?
dwirch posted on May 25, 2017 at about 12:38 in Site News

BWASL returns
dwirch posted on May 13, 2017 at about 15:24 in Site News