How to add directory to path windows

Для быстрого доступа к командам в командной строке без необходимости ввода полного пути к исполняемому файлу можно добавить путь к папке с этими исполняемыми файлами в переменную PATH в Windows, особенно это может быть полезным при работе с adb, pip и python, git, java и другими средствами разработки с отладки.

В этой пошаговой инструкции о том, как добавить нужный путь в системную переменную PATH в Windows 11, Windows 10 или другой версии системы: во всех актуальных версиях ОС действия будут одинаковыми, а сделать это можно как в графическом интерфейсе, так и в командной строке или PowerShell. Отдельная инструкция про переменные среды в целом: Переменные среды Windows 11 и Windows 10.

Добавление пути в PATH в Свойствах системы

Для возможности запуска команд простым обращением к исполняемому файлу без указания пути, чтобы это не вызывало ошибок вида «Не является внутренней или внешней командой, исполняемой программой или пакетным файлом», необходимо добавить путь к этому файлу в переменную среды PATH.

Шаги будут следующими:

  1. Нажмите клавиши Win+R на клавиатуре (в Windows 11 и Windows 10 можно нажать правой кнопкой мыши по кнопке Пуск и выбрать пункт «Выполнить»), введите sysdm.cpl в окно «Выполнить» и нажмите Enter.
  2. Перейдите на вкладку «Дополнительно» и нажмите кнопку «Переменные среды».
    Открыть настройки переменных среды Windows

  3. Вы увидите список переменных среды пользователя (вверху) и системных переменных (внизу). PATH присутствует в обоих расположениях.
    Переменная среды PATH пользователя и системная

  4. Если вы хотите добавить свой путь в PATH только для текущего пользователя, выберите «Path» в верхней части и нажмите «Изменить» (или дважды нажмите по переменной PATH в списке). Если для всех пользователей — то же самое в нижней части.
  5. Для добавления нового пути нажмите «Создать», а затем впишите новый путь, который требуется добавить в переменную PATH в новой строке. Вместо нажатия «Создать» можно дважды кликнуть по новой строке для ввода нового пути.
    Добавление папки в переменную PATH

  6. После ввода всех необходимых путей нажмите «Ок» — ваша папка или папки добавлены в переменную PATH.

Внимание: после добавления пути в переменную PATH потребуется перезапустить командную строку (если она была запущена в момент изменения), чтобы использовать команды без указания полного пути.

Как добавить путь в переменную PATH в командной строке и PowerShell

Вы можете добавить переменную PATH для текущей сессии в консоли: то есть она будет работать до следующего запуска командной строки. Для этого используйте команду:

set PATH=%PATH%;C:\ваш\путь

Есть возможность добавить путь в PATH с помощью командной строки и на постоянной основе (внимание: есть отзывы, что может повредить записи в переменной PATH, а сами изменения производятся для системной переменной PATH), команда будет следующей:

setx /M path "%path%;C:\ваш\путь"
Добавление в PATH в командной строке

Набор команд для добавления пути в переменную PATH пользователя с помощью PowerShell:

$PATH = [Environment]::GetEnvironmentVariable("PATH")
$my_path = "C:\ваш\путь"
[Environment]::SetEnvironmentVariable("PATH", "$PATH;$my_path", "User")

Если требуется добавить путь в системную переменную PATH для всех пользователей, последнюю команду изменяем на:

[Environment]::SetEnvironmentVariable("PATH", "$PATH;$my_path", "Machine")

Table of Contents

PATH is an environment variable that specifies a set of directories, separated with semicolons (;), where executable programs or scripts are located. In this post we will show you how to add a directory to Windows PATH permanently or for the current session only.

Environment variable scopes

Before you are moving forward, you should know about the Scope. On Windows, environment variables can be defined in three scopes:

  • Process (or session) scope: The Process scope contains the environment variables available in the current process, or PowerShell session. This list of variables is inherited from the parent process and is constructed from the variables in the Machine and User scopes. Closing the PowerShell window will revert the environment variables to its pre-determined state.
  • User scope: User environment variables are specific only to the currently logged-in user.
  • System (or Machine) scope: System environment variables are globally accessed by all users.

Add a Directory to Windows %PATH% Environment Variables

For example, we have a simple PowerShell script located at D:\scripts\resetwsl.ps1 that reset then reinstall an WSL instance automatically.

wsl --unregister alpine
wsl --import alpine 'D:\wsl\import\alpine' 'D:\wsl\export\alpine.tar'

As you can see in the below output, to execute the reset script, we need to type the full path of the script or navigate to the script location.

#Output
PS C:\> D:\scripts\resetwsl.ps1
Unregistering.
The operation completed successfully.
Import in progress, this may take a few minutes.
The operation completed successfully.
PS C:\>
PS C:\> cd D:\scripts\
PS D:\scripts> .\resetwsl.ps1
Unregistering.
The operation completed successfully.
Import in progress, this may take a few minutes.
The operation completed successfully.

To simplify the process, after opening a new PowerShell window, we want to type the name of the script only to run it instead of typing the full path or navigating to the script location like this:

As you can see, PowerShell does not recognize the script because it only finds the scripts and executable files in the folders listed in the Path environment variables.

To achieve that goal, we need to add the home path (folder) of the scripts to the Path environment variables. In our case, we need to add D:\Scripts folder to the path environment variables.

Add a value to the Path environment variable (Process scope)

1. In PowerShell we can get the list of directories in the PATH environment variables using the below command:

The output will show the values of the path environment variables. It is including the values in process, user and system scopes.

# Output
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Users\mpnadmin\AppData\Local\Microsoft\WindowsApps
C:\Users\mpnadmin\AppData\Local\Programs\oh-my-posh\bin
C:\Users\mpnadmin\AppData\Local\Programs\Microsoft VS Code\bin

2. To add a new directory to the Path environment, you will need to append your new path to the path variables by performing a simple string operation.

Note
Note: Don’t forget to add the semicolon (;), which will act as a separator between your file paths, and the plus (+) operator to append the value to the environment variables.

$Env:PATH += ";D:\Scripts"
# Output
PS C:\> $Env:PATH += ";D:\Scripts"
PS C:\> $Env:PATH -split ";"
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Users\mpnadmin\AppData\Local\Microsoft\WindowsApps
C:\Users\mpnadmin\AppData\Local\Programs\oh-my-posh\bin
C:\Users\mpnadmin\AppData\Local\Programs\Microsoft VS Code\bin
D:\Scripts

After running the command, we can run the script by enter its name (can use Tab for auto completion) instead of typing the full path of the script or navigating to its location.

Note: Using the $Env:PATH variable will only temporarily change the PATH environment variable in the current PowerShell session. Closing the PowerShell window will revert the PATH environment variable to its pre-determined state. To permanently change the value of our PATH environment variable, we can use the following method below.

Add a value to the Path environment variable (User scope)

1. The PATH environment variable is critical for other software as well, and inadvertently overwriting it can cause various problems. To begin, ensure you backup of your current PATH variable values by running the following command.

$Env:PATH >> 'C:\Env_Path.txt'
Get-Content 'C:\Env_Path.txt'

2. Now, to add a folder as a PATH value, use the below code snippet. For example, we will add the folder D:\scripts to the PATH environment variable. The code explanation:

  • $dir: The directory that you want to add as a value in the Path environment variable.
  • $regPath: The path of the Registry key stores environment variables.
  • $currentStrings: The current strings of the path environment variable.
  • $newStrings: Use the join operator to combine the current strings with the $dir.
  • Remove-ItemProperty: Remove the Path value name of the HKCU:\Environment key.
  • New-ItemProperty: Recreate the value name with the new string ($newStrings)
# Don't forget to change the directory to fit with yours
$dir = "D:\Scripts"

$regPath        = "HKCU:\Environment"
$currentStrings = (Get-ItemProperty $regPath ).Path
$newStrings     = -join($currentStrings,$dir,";")

Remove-ItemProperty -Path $regPath -Name "Path" -Force
New-ItemProperty -Path $regPath -PropertyType 'ExpandString' -Name 'Path' -Value "$newStrings"

As you can see, the D:\Scripts has been added as a value of the Path environment variable.

# Output - The Path value is truncated
Path         : C:\Users\mpnadmin\AppData\Local\Microsoft\WindowsApps;...;D:\Scripts;
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Environment
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName  : Environment
PSDrive      : HKCU
PSProvider   : Microsoft.PowerShell.Core\Registry

How to we know it works? Close the opening PowerShell windows then open a new one then check the path env again using the $env:PATH -split ‘;’ command.

PS C:\> $env:PATH -split ';'
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Users\mpnadmin\AppData\Local\Microsoft\WindowsApps
C:\Users\mpnadmin\AppData\Local\Programs\oh-my-posh\bin
C:\Users\mpnadmin\AppData\Local\Programs\Microsoft VS Code\bin
D:\Scripts

In the feature, the script should be executed by enter its name (can use Tab for auto completion) instead of typing the full path of the script or navigating to its location.

Add a value to the Path environment variable (System scope)

Note: The previous code snippet will add the folder to the PATH environment variable in user scope. If you want to do it in system scope (all users). You can use the following code snippet:

# Don't forget to change the directory to fit with yours
$dir = "D:\Scripts"

$regPath        = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$currentStrings = (Get-ItemProperty -Path $regPath).Path
$newStrings     = -join($currentStrings,$dir,";")

Remove-ItemProperty -Path $regPath -Name "Path" -Force
New-ItemProperty -Path $regPath -PropertyType 'ExpandString' -Name 'Path' -Value "$newStrings"

Set environment variables in your profile

A PowerShell profile is a script that runs when PowerShell starts. You can use the profile as a startup script to customize your environment. You can add commands, aliases, functions, variables, modules, PowerShell drives and more. They’re available in every session without having to import or re-create them.

If you’re writing the PowerShell script to run locally on your computer. You can use the PowerShell profile to add a directory to the path environment variables. Every time you start a PowerShell session the variables would be added automatically.

PowerShell supports several profiles for users and host programs. However, it doesn’t create the profiles for you. Let’s run the below command to create a profile for you if it does not exist.

if(!(Test-Path $profile)){New-Item -Type File -Path $profile -Force}

On the PowerShell profile is created, open it using Notepad then add $Env:PATH += ‘;D:\Scripts’. Close Notepad and save the file.

From now, every time when open a PowerShell session:

  1. The PowerShell profile is loaded.
  2. The command $Env:PATH += ‘;D:\Scripts’ is executed automatically.
  3. And then the folder D:\Scripts would be added as a path environment variable for the session.

Fb6Gw2SzrGfid1CVcPQFb2WNQPqQdWKPZ5Eiw6OXYdKHMF23rGd7AgX4lpvk

Additionally, the command could be added to the PowerShell profile usinh the below command:

Add-Content $PROFILE -Value "`$Env:PATH += ';D:\Scripts'"

Using the Add-Content cmdlet, you can append more paths to the PowerShell profile ($profile) automatically when running your script.

PS C:\> Add-Content $PROFILE -Value "`$Env:PATH += ';D:\Scripts'"
PS C:\> Add-Content $PROFILE -Value "`$Env:PATH += ';C:\Scripts'"

PS C:\> Get-Content $PROFILE
$Env:PATH += ';D:\Scripts'
$Env:PATH += ';C:\Scripts'

To verify it works, open a new PowerShell session then check if D:\Scripts is added automatically.

caUUF7Mk3GJCF4sdEbv8jGMWPj5EGlYKk2EYucImFrO5nABPmlJOKktJRNl1

Because it’s automatically added every time you start PowerShell. So, we can consider it is persistent.

PowerShell execution policy

In the first time after creating the PowerShell profile, when starting PowerShell, you could get the below error:

. : File C:\Users\WDAGUtilityAccount\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\Users\WDAGUtilityAccount\Documents\WindowsPowerShell\Microsoft. ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

You get it because by default, Windows does not allow to run any PowerShell script. PowerShell profile is a PowerShell script, so, it is blocked from running.

PS C:\> $PROFILE
C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

To fix it, let’s run the below command in an elevated PowerShell session. Close then re-open PowerShell to see it works without any error.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

Why it seems complicated?

When using the PowerShell code snippet to add a folder as a value of the Path environment variables. You may wonder Why it looks complicated?

As we show you in the first part of this post, most of the articles on the internet guide you to use the below simple command to add a directory to the Path environment variables. For example, add D:\Scripts to the env:

$Env:PATH += ";D:\Scripts"

You can see, it works as expected but it’s not persistent. Closing the PowerShell window and then re-open a new one will revert the environment variables to its pre-determined state because it’s process scope.

PS C:\> $Env:PATH += ";D:\Scripts"
PS C:\> $env:PATH -split ";"
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Users\admin\AppData\Local\Microsoft\WindowsApps
C:\Users\admin\AppData\Local\Programs\oh-my-posh\bin
C:\Users\admin\AppData\Local\Programs\Microsoft VS Code\bin
D:\Scripts

Some other guides on the internet tell you using the below command to persistent add a value to path environment variables in PowerShell:

setx PATH "$Env:PATH;D:\scripts"
PS C:\> setx PATH "$Env:PATH;D:\scripts"
SUCCESS: Specified value was saved.

The answer is YES BUT NOT RECOMMENED, when you get the values of the path environment variables. You will see, setx duplicates values from a scope to another one.

PS C:\> $Env:PATH -split ";"
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Users\admin\AppData\Local\Microsoft\WindowsApps
C:\Users\admin\AppData\Local\Programs\oh-my-posh\bin
C:\Users\admin\AppData\Local\Programs\Microsoft VS Code\bin
D:\Scripts
D:\scripts

So, DO NOT USE setx command to add a Path in the environment variables.

Add a Directory to PATH Environment Variables in GUI

Alternatively, if you don’t want to do it using PowerShell. You can do it with GUI from Control Panel.

1. Type env into the search box, under the best match select Edit the system environment variables.

PZYOB7XxNDHkveS0DMtGuHwSdFdwfcLJigCrBJY3stuL5qLlJTar4YDzJBZv

2. In the System Properties window, select Environment Variables…

BAZLK9KR08D9TB2MWe1pmExh0DbTQiKR08DojchqGO2kNE8I10HTrRRMBDIp

3. You can add the folder to either user or system variables. For instance, we will add it to the PATH environment variable in the user scope. Select PathEdit…

2P20lMkRALcY877wfPJ8ifaL1vdHJjNhyY0IFig3ZjUesYXNfxDxycyrpW0p

4. Click New → Enter the path of the folder you want to add to. In our case, we add D:\Scripts.

ONwnCvKWNaMwhLl47vzYnVJb8ZzZPBXvgmcomjgbCgLkqNrS01ucCOYr9Xfu

5. Click OK three times to save the changes.

Finally, open a new PowerShell window, from now, we can run the script by enter its name (can use Tab for auto completion) instead of typing the full path of the script or navigating to its location.

The Path environment variable feature in Windows is very important because it lets your computer know where to find the programs when you run them through Command Prompt. For example, if you add a folder path to the “Path” environment variable, you can run any program in that path by entering only its name (e.g. “name.exe”) instead of its whole address every time you want to run it.

This guide will show you how to add a folder to the Path environment variable in Windows 11 or 10. Doing this for a program you often run will save you a lot of hassle and time when executing commands that involve the program.

Add Folder to Path Environment Variable in Windows 11 10

What is the “Path” environment variable?

The Path environment variable is like a list inside your Windows operating system that helps your computer find and run programs directly from a command prompt or PowerShell without needing the full address of the program. It’s a bunch of folder addresses stuck together with semicolons (;). When you try to start a program, Windows looks through these folders in the order they’re listed to find the program’s executable file.

The big deal about the Path variable is it will truly save you a lot of time. Instead of typing the full path every time you want to run a program, you can just tell your computer to run it by typing only its name, and if the program’s folder is in the Path, Windows will know where to find it.

Related issue: Batch (.BAT) Files Not Running in Windows 11/10

Here’s what a Path environment variable look like:

C:\Windows\system32;C:\Windows;C:\Program Files\Java\jdk1.8.0_281\bin

In this example, there are three directories listed. If you run a command, Windows will check these directories in this order to find the program you’re trying to start. If it’s not in any of these, you’ll see an error message.

“[Program] is not recognized as an internal or external command” error

If you’re trying to run a program called “custom-command,” but its folder isn’t listed in the Path. When you try to start it, you might see an error saying:

'custom-command' is not recognized as an internal or external command, operable program or batch file.

is not recognized as an internal or external command Windows 11

This error means Windows can’t find the program in any of the Path directories. To fix this, you need to add the program’s folder to the Path, which we’ll talk about next, or simply type the full path to the program.

Useful tip: How to List Installed Programs in Windows 11

How to add a folder to the “Path” environment variable in Windows 11 or 10

Adding a folder to the Path can be done through a few methods – the system properties, CMD or PowerShell. Choose a method that you’re comfortable with.

Using System Properties

This method should be the easiest and most friendly for people who are not very into commands because it uses the graphical interface of the System Properties window to add or change the Path.

  1. Hit Windows + X and choose “System” from the menu that pops up.
  2. In the System window, click on “Advanced system settings” on the right.
    Windows 11 advanced system settings

  3. Go to the “Advanced” tab in the System Properties dialog and hit the “Environment Variables” button.
    View Environment Variables Windows 11

  4. Find the “Path” variable under “System variables,” select it, and press “Edit.” This opens the “Edit environment variable” window.
    Add Directory to Path Environment Variable Windows 11 10

  5. Here, you’ll see all the folders already in the Path. To add a new one, click “New” and type or paste its address. Tip: Use the “Copy as Path” option to get the folder path right, starting from the root (like C:\Users\YourUsername\custom-folder).
    Add Folder to Path Environment Variable in Windows 11 10

  6. Hit “OK” when you’re done. Your new folder is now part of the Path, and Windows will check it when looking for programs to run.

See also: Change File(s) Date & Timestamp via CMD or PowerShell

Using Command Prompt

In this method, you will use the Command Prompt to change the Path environment variable.

  1. Start a Command Prompt with admin rights by right-clicking on the Start button, choosing “Windows Terminal (Admin)”, and then picking “Command Prompt” from the list.
    Open Command Prompt from Windows Terminal

  2. Type this command, but use your own folder path instead of “YourFolderPath”:
    setx PATH "%PATH%;YourFolderPath"

    This adds your new folder path to the current Path variable. It’s important to keep the “%PATH%;” part to not lose the paths already there.
    To add the folder path in the system environment and prevents the system Path from being duplicated in the user Path, add the /M option like this:

    setx /M PATH "%PATH%;YourFolderPath"

    Add Folder to Path Environment Variable CMD

  3. Close the Command Prompt and open it again to see your changes. Your new folder should now be part of the Path environment variable.

Using PowerShell

This method involves PowerShell to update the Path environment variable.

  1. Open PowerShell with admin rights by right-clicking on the Start button and choosing “Windows Terminal (Admin)”.
  2. Type this command, swapping “YourFolderPath” with your folder path:
    [Environment]::SetEnvironmentVariable("Path",
    [Environment]::GetEnvironmentVariable("Path",
    [EnvironmentVariableTarget]::Machine) + ";YourFolderPath",
    [EnvironmentVariableTarget]::Machine)
    

    Add Folder to Path Environment Variable PowerShell

    This gets the current Path variable, adds your new folder path, and then updates the Path variable. The “;YourFolderPath” adds your new folder after the existing paths.

  3. Close PowerShell and open it again to check the changes. Your new folder should now be in the Path environment variable.

Note: If you need to write a multi-line command in PowerShell, press Shift + Enter to go to a new line without running the command. Press Enter to run it after you’ve typed all of it. This can be helpful for long commands or scripts.

Checking the changes

To make sure the folder is now in the Path environment variable, open a new Command Prompt window and type:

echo %PATH%

Look at the output and check if the folder path you added is there.

Check Path Environment Variable Windows 11 10

Some common issues

The below are some common problems you might encounter when adding a folder to the Path environment variable in Windows.

  • If CMD still gives you error after adding the path of a program you want to run, double-check for typos or mistakes in the folder path. It should be a full path without special characters.
  • Changes to the Path variable only affect new Command Prompt or PowerShell sessions. Restart them to see the changes.
  • If there’s still a problem, there might be a conflict with other software. Look through the Path variable for any outdated or duplicate paths and remove them.

Other common mistakes

It’s easy to make a small mistake that can cause big problems when you’re updating the Path variable.

  • Always back up the current state of the Path variable before making changes. This way, if something goes wrong, you can simply restore it to its original state.
  • Never delete the existing entries in the Path variable unless you are certain they are no longer needed. Removing important paths can stop other programs from running properly.

One last thing: Knowing Path variable priorities

The order of paths in the Path variable matters a lot because Windows checks them in sequence to find the executable files.

If two folders in the Path contain an executable with the same name, Windows will run the one in the folder that appears first in the Path order. You might want to place frequently accessed program directories higher up in the Path to speed up their launch times.

Download Article

A simple guide to adding directories to the system or user path variable

Download Article

  • Using Advanced System Settings
  • |

  • Using Command Prompt
  • |

  • Video
  • |

  • Warnings

The PATH environment variable specifies which directories the Windows command line looks for executable binaries. If you want to edit the PATH on Windows 11 or Windows 10, the process is easy, though not obvious at first. Read on to learn how to add, remove, and edit directories in the system PATH and user PATH environment variables on a Windows PC.

Editing the Path in Windows 11 & 10

1. Right-click the Start menu and select System.
2. Go to Advanced system settings > Environment Variables…
3. Select PATH under «System variables» or «User variables.»
4. Click Edit.
5. Click New.
6. Enter the directory path and click OK.

  1. Step 1 Right-click the Start menu and select System.

    Right-clicking the Start menu brings up the Power User menu, which has different options. You can also get to this menu using the keyboard shortcut Control + X.

  2. Step 2 Click Advanced system settings.

    You will see this option in the «Related links» section on the right panel. This opens the System Properties panel to the «Advanced» tab.

    Advertisement

  3. Step 3 Click Environment Variables….

    This button is near the bottom of the window, below the «Startup and Recovery» section.

  4. Step 4 Select Path under "System variables."

    Alternatively, if you only want to edit the path for your user account, not the entire system, select Path under «User variables» instead.

    • You may have to scroll down to find the Path variable.
  5. Step 5 Click the Edit button.

    This takes you to a screen where you can edit the PATH environment variable.

    Warning! DO NOT remove any variables unless you know what you’re doing.

  6. Step 6 Click New to add a new folder to the path.

    You’ll see this button at the top-right corner of the window.

    • If you want to edit an existing folder path, select it and click Edit instead. Then, modify the path as needed and click OK to save your changes.
    • To remove a directory from the PATH, select it, then click the Delete button.
  7. Step 7 Enter the folder you want to add to your path.

    Type the full path to the directory you’re adding. For example, if you’re adding FFmpeg to your path, you’ll usually want to add C:\ffmpeg\bin. For Java, it’ll usually be something like C:\Program Files\Java\jdk-23\bin.

  8. Step 8 Click OK, then OK again.

    Keep clicking OK until you’ve closed out of System Properties completely.

  9. Step 9 Open a new Command Prompt window and check the path.

    If you were working in an existing Command Prompt window, you’ll need to close it and open a new one to verify that you’ve added the path correctly. Once you’re there, type echo %PATH% and press Enter–you should now see the folder you added to your path in the list.

    • Alternatively, if you’re using PowerShell, you can echo the path using the command $env:Path -split ';'.
  10. Advertisement

  1. Step 1 Open Command Prompt as an administrator.

    If you want to add a directory to the system PATH in CMD, it’s super easy. To open Command Prompt as an admin, click the Start menu, type cmd, right-click Command Prompt, and select Run as administrator.

    • If you’re just editing the user PATH and not the system PATH, you don’t need to open Command Prompt as an administrator.
    • Important: Editing the PATH environment variable from the Command Prompt using the setx command is not typically recommended–setx merges the system and user PATHs and truncates the PATH to 1024 characters. If the directories in your PATH amount to more characters than that, you’ll likely break things. When possible, use Advanced System Settings instead.
    • If you’re on a school or work computer and don’t have permission to edit the PATH environment variable, ask your system administrator if there’s a utility installed to do this, such as pathman or pathed.
  2. Step 2 Add a folder to the user PATH.

    If you don’t need to make the change for all users of the system, the syntax is setx "%path%;C:\directory". Replace C:\directory with the full path of the folder you want to add to the path.

    • For example, if you’re adding JDK23 to your path, use setx "%path%;C:\Program Files\Java\jdk-23\bin".
    • This change will not take effect in the current Command Prompt window–you will need to open a new Command Prompt window to test your change.
  3. Step 3 Add a folder to the system PATH.

    To make it so the directory you are adding is added to the path for all users of the system, you’ll run the same command, but with the /M parameter. For example, setx /M "%path%;C:\Program Files\Java\jdk-23\bin" adds C:\Program Files\Java\jdk-23\bin to the PATH for all users of this system.

  4. Step 4 Open a new Command Prompt window and check the path.

    If you were working in an existing Command Prompt window, you’ll need to close it and open a new one to verify that you’ve added the path correctly. Once you’re there, type echo %PATH% and press Enter–you should now see the folder you added to your path in the list.

  5. Advertisement

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Video

Thanks for submitting a tip for review!

  • Changing the PATH environment variable incorrectly can cause your system to stop working correctly. Before changing PATH, you should have a basic understanding of what you’re doing.

Advertisement

About This Article

Thanks to all authors for creating a page that has been read 111,494 times.

Is this article up to date?

If you’re a coder or programmer, you probably spend a decent amount of time using the command prompt to execute programs or compile code. In order to complete those tasks, you most likely have to use a command from a library or software package installed (like Python) on your system.

By default, most of these programs will add their own custom shortcuts to the Windows environment variables. The most used environment variable in Windows is probably the PATH variable. It basically allows you to run any executables that are located inside the paths specified in the variable at the command prompt without having to give the full path to the executable.

In this article, I’ll show you how you can add more paths to the Windows PATH variable in case you want to run executables from your own custom directories.  It’s worth noting that the procedure below is for Windows 10, but it’s almost exactly the same for Windows 7 also.

Add Directories to PATH Variable

To get started, right-click on the Computer or This PC icon on the desktop and select Properties. If you don’t have that icon on your desktop already, you can add any missing desktop icons easily.

On the System dialog page, you’ll see an Advanced system settings link on the left-hand side.

This will bring up the System Properties dialog, which should already be open to the Advanced tab. Go ahead and click on the Environment Variables button at the very bottom.

On the Environment Variables dialog, you’ll see two sets of variables: one for user variables and the other for system variables. Both lists have the PATH variable, so you have to decide which one to edit.

If you only need the commands for your own user account, then edit the user variable. If you need it to work across the computer system regardless of which user is logged in, then edit the system variable. Click on Path and then click on Edit.

On the Edit environment variable dialog, you’ll see a list of all the paths that are currently in the PATH variable. As you can see, Node.js and Git already added their paths so that I can run Git commands and Node.js commands from anywhere while in the command prompt.

To add a new path, simply click on New and it’ll add a new line to the bottom of the list. If you know the path, simply type it in or copy and paste it. If you prefer, you can also click Browse and then navigate to the desired path.

To edit any path, simply select it and then click on the Edit button. You can also delete paths using the Delete button. Note that you can also move items up and down on the list. When you type a command at the command prompt, Windows has to search through each directory stored in the PATH variable to see if that executable exists or not. If you want your executable to be found faster, just move that path up to the top of the list.

This can also come in handy if you have multiple versions of the same command in different paths and need to have one run instead of the other. The one that shows up higher in the list will be run when you type in the command.

Lastly, if you click on Edit text, it will load a dialog where you can edit the Path variable using the old interface where all the paths are listed in one text box.

That’s all there is to it! If you want to learn more about environment variables, make sure to check out my post on how to create your own custom environment variables. Enjoy!

Related Posts

  • How to Fix a “This file does not have an app associated with it” Error on Windows
  • How to Fix an Update Error 0x800705b4 on Windows
  • How to Resolve “A JavaScript error occured in the main process” Error on Windows
  • How to Fix the Network Discovery Is Turned Off Error on Windows
  • How to Change Folder Icons in Windows

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Подключиться к удаленному рабочему столу windows 10 онлайн
  • Как установить adb драйвера на windows 7 вручную
  • Перенос windows на flash
  • Нет службы windows update
  • Как сохранить состояние windows