Adding a directory to the PATH environment variable in Windows

To add a directory to the PATH environment variable in Windows, you can follow these steps:

  1. Open the Start menu and search for “Environment Variables” or “Edit the system environment variables.” Select the option that allows you to edit the system environment variables.
  2. In the System Properties window, click on the “Environment Variables” button.
  3. In the Environment Variables window, you’ll see two sections: User variables and System variables. The User variables section contains variables specific to your user account, while the System variables section contains variables accessible by all users on the system. To add a directory for all users, choose a variable from the System variables section (e.g., Path).
  4. Select the variable (Path) and click the “Edit” button.
  5. In the Edit Environment Variable window, click on the “New” button.
  6. Enter the directory path you want to add (e.g., C:\YourDirectory) and click “OK.”
  7. Click “OK” in the Environment Variables window to save the changes.
  8. Close any open command prompt windows and reopen them to ensure the new PATH variable takes effect. Alternatively, you can restart your computer.

Table of Contents

Option 1

After you change PATH with the GUI, close and reopen the console window.

This works because only programs started after the change will see the new PATH.

Option 2

This option only affects your current shell session, not the whole system. Execute this command in the command window you have open:

This command appends C:\your\path\here\ to the current PATH. If your path includes spaces, you do not need to include quote marks.

Breaking it down:

set – A command that changes cmd’s environment variables only for the current cmd session; other programs and the system are unaffected.
PATH= – Signifies that PATH is the environment variable to be temporarily changed.
%PATH%;C:\your\path\here\ – The %PATH% part expands to the current value of PATH, and ;C:\your\path\here\ is then concatenated to it. This becomes the new PATH.

Notify of

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

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x