DI Management Home > Windows Path Variable

Windows Path Variable

On a Windows system, the PATH is an enviroment variable that tells the system where to look for executable files (.exe, .bat), and in which order. First it looks in the current directory, then it looks in each directory in the PATH, in order. It executes the first executable it finds with the given name.

Default PATH

The default PATH for a new Windows installation is usually
For example, to start Notepad you can just type
> notepad
The full path to Notepad is C:\Windows\notepad.exe. Because C:\Windows is in the PATH, then you only need to type "notepad", not the full path name.

See the PATH variable

To see the contents of the PATH variable, open a command-line console and type "PATH"
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{additional paths...}
A lot of programs add their own directory paths to the PATH variable when you install them, so the list of additional paths can get quite long, and the order may vary (as everyone tries to make their own program the first in the list!).

An equivalent way is


Run an executable program using the PATH

To run the executable program sayhello.exe you type "sayhello" on the command line
> sayhello
the system will first look for an executable program with the name "sayhello" in the current directory. If it is not found, the system will look in each directory specified in the PATH variable - in order - and execute the first program it finds with the name "sayhello" (this could also be "sayhello.bat").
> sayhello
Hello World!
If the system does not find any matching executable file, it will print
> sayhello
'sayhello' is not recognized as an internal or external command,
operable program or batch file.
Otherwise, if you have put the executable file in the directory, say, C:\MyFiles\Hello, which is not in the PATH, then you must enter the full path name
> C:\MyFiles\Hello\sayhello
Hello World!
The whole idea of the PATH variable is to save you having to type the full path name each time.

Where to put your program so it is on the PATH

So, you have downloaded a .exe program (say, from our Utilities page). Where do you put it? Here are some choices.
  1. We recommend Setting up a BIN directory for Windows executables C:\Bin. Copy your file there. All done.
  2. Put the file in C:\Windows. It will be found, but this is not recommended. You will need administrative permissions.
  3. Put it in your own new folder, say C:\Program Files\Hello and then add this directory to the PATH variable.

Adding a directory to the PATH temporarily

SET PATH=C:\Program Files\Hello;%PATH%
This will be in effect until the console window is closed.

Note (1) no trailing slash in the directory name and (2) spaces are treated literally in the PATH variable, so you do not add quotes around path names with a space in them.

Executable files

The usual executable files have extensions .exe and .bat. The full list of executable extensions is given by the %PATHEXT% variable. Any file that ends in one of these extensions is considered an executable.
> echo %PATHEXT%

More info

  1. A very useful reference about environmental variables is Computer Hope's What are the default environment variables in Windows?
  2. A more detailed explanation of how to set the PATH in Windows How to set the path and environment variables in Windows

Contact us

To contact us or comment on this page, please send us a message.

This page first published 3 November 2023. Last updated 3 November 2023