What is the PATH?

By | 2006-11-27

Display or set a search path for executable files.

Syntax

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

Key

switchdescription
pathnamedrive 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.

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.

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

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.