How to Set the PATH Variable in Windows

Environment variables are name-value pairs for various programs or processes on an operating system. On Windows, the environment variables store all sorts of information about the operating system environment, such as its path, location of system programs and processes, and other essential data required by other system programs.

setting path variable in windows

Of the different kinds of Windows environment variables, one that plays an important role—and impacts the way programs and commands get executed—is the PATH environment variable.

If you’re wondering why you’d want to set the PATH variable and how to do it, here’s a guide explaining the same in detail.

Table of Contents

Why Would You Want to Set the PATH Variable?

PATH is an essential environment variable
on all Windows operating systems. It determines the way a system executes a program or command on your computer.

Typically, when you have to launch a program or execute a command, you have two options. Either you can navigate to the directory where the program/command is stored and execute it from there. Or, you can use the absolute path for that program/command in the file system to run it from anywhere.

While both approaches let you execute programs or commands via the CLI (Command Prompt or PowerShell), they aren’t very efficient. A better solution here is to set the PATH variable for those programs or commands in the environment variable so you can access them from anywhere on the file system hierarchy.

For example, with Python installation, unless the installer gives you an option to set the PATH automatically, you have to do it explicitly to use Python within any directory on your system. Although this is an optional step, it’s highly recommended that you do so to alleviate the need for using absolute (full) paths while running Python scripts.


Setting the PATH Variable Using GUI

Using the graphical interface is the easiest way to set the PATH variable in Windows. To do this, first, open the Windows Run
prompt by hitting the Windows + R
key shortcut.

Next, in the field beside Open
, type in sysdm.cpl
and press Enter
or click OK
to open System Properties
.

In System Properties
, go to the Advanced
tab and click on the Environment Variables
button at the bottom.

setting the path variable in windows

Now, open File Explorer
and head to the installation directory of the program you want to add to PATH. Press and hold the Shift
key, right-click on the folder, and select Copy as Path
.

In the Environment Variables
window, click on the Path
variable name from either section and hit the Edit
button. On Windows 7 and Windows 8, add a semi-colon at the end of the line, and without leaving a space, paste the program’s path you just copied into the Path
field.

setting the path variable in windows

If you’re on Windows 10, hit the New
button and paste the copied path on the new line. Alternatively, hit the Edit text
, add a semi-colon to the end of the field for Variable value
, and paste the program’s path.

setting the path variable in windows


Setting the PATH Variable Using CLI

set PATH=”C:\Program Files\Android\Platform-Tools”

However, this command sets PATH temporarily (only for the current session) and resets it to the default PATH entries upon system reboot.

So, if you’d like to set PATH for a program permanently—such that it persists even after rebooting the PC—you need to use the setx
command.

setx PATH "value;%PATH%"

setx PATH "C:\Program Files\Android\Platform-Tools;%PATH%"

setx /m PATH "C:\Windows\System32;%PATH%"

Once done, restart CMD.

How to Unset the PATH Variable

Open Run
and enter:

In System Properties
, tap on the Advanced
tab and click the Environment Variables
button at the bottom. Next, click on the Path
entry from either section in the Environment Variables
window—depending on whether you set the PATH temporarily or permanently—and hit the Edit
button.

Tap on the entry you want to remove to select it and hit the Delete
button on the right. On older versions of Windows, you can click the Edit text
button and delete the recent PATH entry for the Variable value
text field.

setting the path variable in windows

Hit OK
to save the changes.

Running Programs/Commands From Anywhere With the CLI

Once you’ve set the PATH variable on your computer to include the path (or directory) of the program or command you want to execute from any directory, you can easily run it from Command Prompt or PowerShell without ever having to specify its absolute path.

FAQs About Setting the PATH Variable in Windows


1. How do I set the PATH variable in Windows 10?

On Windows 10, you can set the PATH variable either using the GUI or CLI. With GUI, you need to go into the Environment Variables settings and set/modify the PATH variable from there, whereas in the CLI approach, all you need to do is run a couple of commands in the CMD prompt, and you’ll have the PATH variable for your desired program set.

:/>  Update Agent 7.6.7600.256 x86


2. Does Windows have a PATH variable?

All Windows operating systems have the PATH variable as part of the environment variables, and by setting it for your most frequently used programs or commands, you can launch them from any directory in the file system without having to specify their absolute path.


3. How do I permanently set a PATH variable?

Permanently setting a PATH variable is possible via both GUI and CLI methods. With the GUI method, you’ll have to go into the Environment Variables setting and set the PATH for your program or command there. On the other hand, the CLI method simplifies this process and only involves using a command ( setx
) in the Command Prompt, which saves you the hassle of clicking through various menus.


4. How do I find my PATH in CMD?

Was this article helpful?

Updated: by

Setting the path and variables in Windows 11

  1. Press the Windows key
    + X

    to access the Power User Task Menu
    .
  2. In the Power User Task Menu, select the System
    option.
  3. In the System > About
    window, click the Advanced system settings
    link below the Device specifications
    section.
  4. In the System Properties
    window, click the Advanced
    tab,if not already selected.
  5. Click the Environment Variables
    button
    near the bottom-right of the Advanced
    tab.
  6. In the Environment Variables
    window (pictured below), highlight the Path
    variable in the System variables
    section and click the Edit
    button. Add or modify the path lines with the paths you want the computer to access. Each directory path is separated with a semicolon, as shown below.
  C:\Program Files;C:\Winnt;C:\Winnt\System32  

Windows 10 environmental path settings

  1. After creating or modifying the environment variables, restart the computer for those changes to take effect in Windows.

You can edit other environment variables by highlighting the variable in the System variables
section and clicking Edit
. If you need to create a new environment variable, click New
, and enter the variable name and value.

To view and set the path through the Windows command line, use the path command
.

Setting the path and variables in Windows 10

  1. Press the Windows key
    + X

    to access the Power User Task Menu
    .
  2. In the Power User Task Menu, select the System
    option.
  3. In the About
    window, click the Advanced system settings
    link under Related settings
    on the far-right side.
  4. In the System Properties
    window, click the Advanced
    tab, then click the Environment Variables
    button
    near the bottom of that tab.
  5. In the Environment Variables
    window (pictured below), highlight the Path
    variable in the System variables
    section and click the Edit
    button. Add or modify the path lines with the paths you want the computer to access. Each directory path is separated with a semicolon, as shown below.
  C:\Program Files;C:\Winnt;C:\Winnt\System32  

Windows 10 environmental path settings

  1. After creating or modifying the environment variables, restart the computer for those changes to take effect in Windows.

You can edit other environment variables by highlighting the variable in the System variables
section and clicking Edit
. If you need to create a new environment variable, click New
, and enter the variable name and value.

To view and set the path through the Windows command line, use the path command
.

Setting the path and variables in Windows 8

  1. Press the Windows key
    + X

    to access the Power User Task Menu
    .
  2. In the Power User Task Menu, select the System
    option.
  3. Click the Advanced System Settings
    link in the left column.
  4. In the System Properties
    window, click the Advanced
    tab, then click the Environment Variables
    button
    near the bottom of that tab.
  5. In the Environment Variables
    window (pictured below), highlight the Path
    variable in the System variables
    section and click the Edit
    button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
  C:\Program Files;C:\Winnt;C:\Winnt\System32  

Windows environmental path settings

  1. After creating or modifying the environment variables, restart the computer for those changes to take effect in Windows.

You can edit other environment variables by highlighting the variable in the System variables
section and clicking Edit
. If you need to create a new environment variable, click New
, and enter the variable name and value.

To view and set the path through the Windows command line, use the path command
.

Setting the path and variables in Windows Vista and Windows 7

  1. On the desktop
    , right-click the Computer
    icon and select Properties
    . If you don’t have a Computer icon on your desktop, click Start
    , right-click the Computer
    option in the Start menu
    , and select Properties
    .
  2. Click the Advanced System Settings
    link in the left column.
  3. In the System Properties
    window, click the Advanced
    tab, then click the Environment Variables
    button
    near the bottom of that tab.
  4. In the Environment Variables
    window (pictured below), highlight the Path
    variable in the System variables
    section and click the Edit
    button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
  C:\Program Files;C:\Winnt;C:\Winnt\System32  

Windows environmental path settings

  1. After creating or modifying the environment variables, restart the computer for those changes to take effect in Windows.
:/>  Как записать образ на флешку

You can edit other environment variables by highlighting the variable in the System variables
section and clicking Edit
. If you need to create a new environment variable, click New
, and enter the variable name and value.

To view and set the path through the Windows command line, use the path command
.

Setting the path and variables in Windows 2000 and Windows XP

  1. From the desktop
    , right-click My Computer
    and click Properties
    . If you don’t have a My Computer icon on your desktop, click Start
    , right-click the My Computer
    option in the Start menu, and select Properties
    .
  2. In the System Properties
    window
    , click the Advanced
    tab
    .
  3. In the Advanced
    section, click the Environment Variables
    button
    .
  4. In the Environment Variables
    window (as shown below), highlight the Path
    variable in the System Variable
    section and click the Edit
    button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
  C:\Program Files;C:\Winnt;C:\Winnt\System32  

Windows environmental path settings

  1. After creating or modifying the environment variables, restart the computer for those changes to take effect in Windows.

You can edit other environment variables by highlighting the variable in the System variables
section and clicking Edit
. If you need to create a new environment variable, click New
, and enter the variable name and value.

To view and set the path through the Windows command line, use the path command
.

What is the default Windows %PATH%?

The path is based on programs installed on the computer, so there is no “default path.” However, the Windows minimum path
is often the path below.

  %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem  

Keep in mind that as you install programs, the path is updated with the paths for the newly installed programs. So, if you have erased your path after installing other programs, those programs may be affected.

Setting path in the MS-DOS and Windows command line

To view and set the path in MS-DOS and the Windows command line, use the path command
.

The most efficient way to get most things done on Windows is via the graphical interface. Every now and then, though, you have to turn to the command line for troubleshooting, programming, or just working on your nerd cred.

But if you’re trying to run something that’s not natively part of Windows, you’ll need to add it to your PATH variable. That tells your system where to look for executables when you ask for them.

Windows Path Python Example

Windows Path Charmap Launch

On Windows, PATH (capitalized by convention only, since Windows’ NTFS file system is not case-sensitive) points by default to the “C:\Windows” and “C:\Windows\system32” directories.

If you type charmap
into the command line, you’ll get a massive list of Unicode characters you can copy and use, for example. “notepad” runs Notepad, “msinfo32” gets you a list of your computer’s specs, and so on.

These programs can also be launched with the GUI. But if you’re already working in the command line, launching programs just by typing their names is a lot easier. This is especially true if you’re trying to launch a program that will open and run inside the command line interface, like Python or Node.js.

How do I edit the PATH variable?

The Windows GUI is pretty straightforward, so it’s probably the best way for most people to edit PATH.

Using the Windows GUI

1. Open “System Properties” and go to the “Advanced” tab. The easiest way to do this is by typing environment variable
into your Windows Search bar and clicking “Edit the system environment variables.”

Windows Path System Properties Search

Alternatively, you can go to “Control Panel -> System and Security -> System” and click “Advanced system settings;” type sysdm.cpl
into the Run command
; or right-click “This PC,” select “Properties,” and click “Advanced system settings.” They all go to the same place.

Windows Path System Properties Advanced

Windows Path Environment Variables

Windows Path Edit Environment Variable

5. If you already have the path to the folder you want to add, just click “New” and paste in the full path (not directly to the executable, just to the folder containing it). I’m pasting in the path to my NodeJS directory so I can use JavaScript in the command line.

Windows Path Edit Environment Variable New

6. If you’d rather browse to the folder and select it manually, use the “Browse” button to navigate to the folder where your executable is located and hit the “OK” button when you’re there.

Windows Path Edit Environment Variables Browse Node

7. If you want your program to launch slightly faster, you can use the “Move Up” and “Move Down” buttons to put its folder closer to the top so it’ll pop up more quickly in the directory search.

8. Open a new command-prompt window and test your program by typing in the name of the executable you want to launch. It won’t work in the current window since it’s still using the old PATH variable.

:/>  10 Лучших программ для обновления драйверов

Edit PATH Variables Using Command Prompt

The Windows 10 GUI is very usable and should meet most peoples’ needs, but if you need to use the command line to set PATH and environment variables, you can do that too.

2. Scroll through the list of paths, then find the variable you want to edit. The variable name
is the part before the ‘=’ sign, the variable value
is the part after, which you will rename to the directory you want it point to.

What Is Windows Path Edit Environment Variable Cmd 1

  setx variable name  
Windows Path Cmd Setx

  setx M PATH  

Frequent Asked Questions

1. Why would I need to edit PATH?

Chances are, if you’re reading this, you’ve run into something that requires you to add it to the PATH variable, so that’s probably what you should do. If you just want to add something to your PATH for easier access, though, that’s also fine. Just make sure it doesn’t interfere with the higher-priority programs.

2. Is there a Windows PATH length limit?

Yes, there is. So PATH-changing enthusiasts beware that the limit is 260 characters.

3. Can I disable the Windows PATH length limit?

Yes you can! Go to the Registry Editor, then within that navigate to:

  \SYSTEM\CurrentControlSet\Control\FileSystem  

In the right-side pane, double-click the entry called “LongPathsEnabled”, then change the “Value data” value from 0 to 1. Click OK, and you’re good to go.

What Is Windows Path Disable Length Limit

Ready to keep digging beneath the Windows bonnet? Then head over to our favorite Windows registry hacks
. Or for something a little lighter, check out our list of the best Windows 10 themes
.

Robert Zak

Content Manager at Make Tech Easier. Enjoys Android, Windows, and tinkering with retro console emulation to breaking point.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sometimes we need to tell Windows where to look for a particular executable file or script. Windows provides a means to do this through the Path Environment Variable
. The Path Environment Variable essentially provides the OS with a list of directories to look in for a particular .exe or file when the simple name of the file is entered at the command prompt.

For example, the Notepad.exe
application resides in the C:\Windows\system32

directory. However, if we wish to open the Notepad application via the Windows Command Line, we need only type:

Opening Notepad.exe From the Windows Command Line:
  C:\Users\John> notepad  

This works because the Path variable on Windows by default contains a list of directories where application files and scripts are likely to be located. Each directory in the list is separated by a semi-colon.

Similarly, there is another environment variable, PATHEXT which specifies a list of file extensions which might be found when searching for the proper file within the paths in the Path variable. This is why we are able to type simply “Notepad” at the command prompt, instead of Notepad.exe.

Once a file with a matching name is located, Windows attempts to match the file extension (if one is present), again in the order specified in the PATHEXT variable. If a match is found, the file is processed accordingly.

Adding a Directory to the User Path Variable from the Command Line

Now, in order to invoke the sqlite3.exe from the command line, we need to add the C:\SQLite
directory to our PATH environment variable. We can do this from the command line by using the
command:

The setx Command – Syntax:
  C:\Users\John> setx "%path%;C:\SQLite"  

We can examine the contents of the PATH variable by typing:

Output PATH Variable to the Console:
  C:\Users\John> echo %PATH%  

Which gives the output:

Results of Echo %PATH% Command:
  C:\Users\John>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Wind
owsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance
Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\
Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\1
10\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\Manage
mentStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Priv
ateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Prog
ram Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Windows Liv
e\Shared;C:\Program Files\Calibre2\;C:\Program Files\Microsoft\Web Platform Inst
aller\;C:\Users\John\AppData\Roaming\npm;C:\Program Files (x86)\nodejs\;C:\Progr
am Files (x86)\Microsoft SDKs\Windows Azure\CLI\wbin;C:\Program Files (x86)\GtkS
harp\2.12\bin;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\SQLite  

Adding a Directory to the System Path Variable from the Command Line

Add a Directory the the System PATH Variable Using the /m Flag:
  C:\Users\John> setx /m path "%path%;C:\SQLite"  

Adding a Directory to the Path Variable from the GUI

Or, we can do this using the GUI by navigating to Control Panel => All Control Panel Items => System
, and then selecting the “Advanced System Settings” link:

Locate Advanced System Settings in Control Panels:

Control PanelAll Control Panel ItemsSystem

Then locate the “Environment Variables” button:

Open Environment Variables:

System Properties

Editing Environment Variables:

Environment Variables

Adding a User Path Variable in the Windows GUI:

add-path-variable

Added Path Variable to User Environment Variables:

New Environment Variables

Removing Directories from the PATH Variable

Additional Resources and Items of Interest

Оставьте комментарий