Windows how add folder to path

Как добавить путь в переменную PATHДля быстрого доступа к командам в командной строке без необходимости ввода полного пути к исполняемому файлу можно добавить путь к папке с этими исполняемыми файлами в переменную 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")

On StackOverflow and on the net in general, there are outdated and few guides on how to add a specific folder to the Windows 10 Path environment variable of the user.

I think a complete guide for new developers with step by step instructions and screenshots could be really usefull to help them executing utilities from a Command Prompt without the need of the full path, simplifying the things.

wdmssk's user avatar

wdmssk

331 gold badge2 silver badges4 bronze badges

asked May 30, 2017 at 21:40

MatPag's user avatar

For the guide below we want to add an example utility called mytool.exe which is located in C:\Users\NewFolderInPath\mytool.exe, so that everytime i want to execute the mytool utility i don’t have to specify the full path.

I used this as an example, you can replace the folder with something more realistic like the JDK bin directory located here C:\Program Files\Java\{JDK_VERSION}\bin to execute javac, keytool or everything you want.

Step 1 — Click on the Windows icon

enter image description here

Step 2 — Click on the Settings icon

enter image description here

Step 3 — Click on System

enter image description here

Step 4 — Click on About

enter image description here

Step 5 — Click on System info

enter image description here

Step 6 — Click on Advanced system settings

enter image description here

Step 7 — Click on Environment variables...

enter image description here

Step 8 — Select Path row and then click Edit

enter image description here

Step 9 — Click New and then click Browse, then in the next panel which will open you need to select the folder you want in the Path. For the initial premise of this guide i will add the folder C:\Users\NewFolderInPath

enter image description here

Step 10 — Click OK and click every OK button you will encounter to close every previous windows.

enter image description here

Step 11 — Open a command prompt (cmd) and now you can execute your utility without specifying the full path.

enter image description here

starball's user avatar

starball

22.1k8 gold badges47 silver badges286 bronze badges

answered May 30, 2017 at 21:40

MatPag's user avatar

MatPagMatPag

42k14 gold badges106 silver badges115 bronze badges

3

To print each entry of Windows PATH variable on a new line, execute:

C:\> echo %PATH:;=&echo.%

Set Windows PATH variable for the current session:

C:\> set PATH=%PATH%;C:\path\to\directory\

Set Windows PATH Permanently

Run as Administrator: The setx command is only available starting from Windows 7 and requires elevated command prompt.

Permanently add a directory to the user PATH variable:

C:\> setx path "%PATH%;C:\path\to\directory\"

Permanently add a directory to the system PATH variable (for all users):

C:\> setx /M path "%PATH%;C:\path\to\directory\"

answered Sep 29, 2021 at 22:02

HackSlash's user avatar

HackSlashHackSlash

4,9332 gold badges18 silver badges45 bronze badges

The Path environment variable in Windows is a crucial system variable that stores the location of directories containing executable programs. It enables you to run these programs from any command prompt or PowerShell window without specifying their full path.

This article will provide a detailed, step-by-step guide on how to add a folder to the Path environment variable in Windows 11 and Windows 10. By following this guide, you can easily and efficiently manage the system path on your computer.

Add Folder to Path Environment Variable in Windows 11 10

What is the “Path” Environment Variable?

The Path environment variable is a critical component of the Windows operating system, as it allows you to run executable programs from any command prompt or PowerShell window without specifying their full path. The variable is a string that contains a list of directory paths separated by semicolons (;). When you enter a command or attempt to run a program, the system searches through these directories in the order they are listed, looking for the executable file associated with the command or program.

The primary purpose of the Path environment variable is to enable users to run essential programs or commands without having to navigate to the specific directory containing the executable file each time. By including the necessary directories in the Path variable, you can simplify your workflow and increase productivity.

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

Example of a Path environment variable

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

In the example above, the Path environment variable contains three directories. When a command is entered, the system will search for the executable file in the following order:

  1. C:\Windows\system32
  2. C:\Windows
  3. C:\Program Files\Java\jdk1.8.0_281\bin

If the executable is not found in any of these directories, the system will return an error message.

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

Example: Consider a scenario where you are attempting to run a command or program called “custom-command,” but the directory containing the “custom-command.exe” file has not been added to the Path environment variable. In this case, when you try to run “custom-command” from the command prompt or PowerShell, you may receive an error message similar to the following:

'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 message indicates that the system could not find the executable associated with “custom-command” in any of the directories listed in the Path environment variable. To resolve this issue, you would need to add the directory containing “custom-command.exe” to the Path variable, as described in the next section of this article.

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 environment variable allows the system to recognize and execute programs stored in that folder without needing to navigate to it or specify its full path. The following elaborates on the three methods for adding a folder to the Path environment variable:

Using System Properties

This method involves using the graphical user interface (GUI) of the System Properties window to edit the Path variable.

  1. Press Windows + X and select “System” from the context menu that appears.
  2. In the System window, click on “Advanced system settings” in the right panel.Windows 11 advanced system settings
  3. In the System Properties dialog, switch to the “Advanced” tab and click on the “Environment Variables” button.View Environment Variables Windows 11
  4. Under the “System variables” section, scroll down and locate the “Path” variable. Select it and click on the “Edit” button. This will open the “Edit environment variable” window.Add Directory to Path Environment Variable Windows 11 10
  5. In this window, you will see a list of existing directories included in the Path variable. To add a new folder path, click on the “New” button and type or paste the folder path you want to include. Tip: To avoid errors when entering the folder path, use the “Copy as Path” feature instead of manually typing the full path. Make sure to use an absolute path, which starts from the root directory (e.g., C:\Users\YourUsername\custom-folder). Add Folder to Path Environment Variable in Windows 11 10
  6. Once you have added the folder path, click “OK” to save your changes. The new folder is now included in the Path environment variable, and the system will search this folder when looking for executable files associated with entered commands.

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

Using Command Prompt

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

  1. Open a Command Prompt with administrative privileges by right-clicking on the Start button, selecting “Windows Terminal (Admin)“, and then choosing “Command Prompt” from the dropdown menu.Open Command Prompt from Windows Terminal
  2. Enter the following command, replacing “YourFolderPath” with the folder path you want to add:
    setx PATH "%PATH%;YourFolderPath"

    This command appends the new folder path to the existing Path variable in the local environment. It is essential to include the “%PATH%;” part to preserve the current paths in the variable.
    To add the folder path to the system environment and prevents the system Path from being duplicated in the user Path, use the following command with the /M option:

    setx /M PATH "%PATH%;YourFolderPath"

    Add Folder to Path Environment Variable CMD

  3. Close the Command Prompt and reopen it to see the changes. The new folder is now included in the Path environment variable.

Using PowerShell

This method involves using PowerShell to update the Path environment variable.

  1. Open PowerShell with administrative privileges by right-clicking on the Start button and selecting “Windows Terminal (Admin)”.
  2. Enter the following command, replacing “YourFolderPath” with the folder path you want to add:
    [Environment]::SetEnvironmentVariable("Path",
    [Environment]::GetEnvironmentVariable("Path",
    [EnvironmentVariableTarget]::Machine) + ";YourFolderPath",
    [EnvironmentVariableTarget]::Machine)
    

    Add Folder to Path Environment Variable PowerShell
    This command retrieves the current Path variable, appends the new folder path, and then sets the updated Path variable. The “;YourFolderPath” part adds the new folder path after the existing paths.

  3. Close PowerShell and reopen it to see the changes. The new folder is now included in the Path environment variable.

Note: If you need to enter a multi-line command in PowerShell, you can use Shift + Enter to create a new line without executing the command. This way, you can enter the entire block of commands one line at a time. Only press Enter to execute when the whole block of commands has been entered. This technique is useful when working with lengthy commands or scripts.

By using any of these three methods, you can successfully add a folder to the Path environment variable in Windows 11 and Windows 10. This allows you to execute programs stored in the added folder without specifying their full path in the command prompt or PowerShell.

Verifying the changes

To verify that the folder has been added to the Path environment variable, open a new Command Prompt window and enter the following command:

echo %PATH%

Check the output and ensure that the folder path you added is present in the list of directories.

Check Path Environment Variable Windows 11 10

Common issues and troubleshooting tips

When working with the Path environment variable in Windows 11 or Windows 10, you may encounter certain issues or difficulties. This section provides an overview of some common problems and offers troubleshooting tips to help you resolve them.

  • If you encounter issues with adding a folder to the Path environment variable, double-check the folder path for typos or incorrect formatting. The folder path should be absolute and not contain any spaces or special characters.
  • Keep in mind that any changes you make to the Path environment variable will only apply to new Command Prompt or PowerShell sessions. Close and reopen the respective terminal to apply the changes.
  • If you still face issues, it is possible that the folder path you added is not being recognized due to conflicts with other paths or software. Review the existing paths in the Path environment variable and remove any duplicate or outdated entries.

Summary

Adding a folder to the Path environment variable in Windows 11 and Windows 10 can significantly streamline your workflow and make it easier to access executables without specifying their full path. With the methods outlined in this article, you can quickly and efficiently manage the system path on your computer. Remember to verify your changes and troubleshoot any issues you may encounter to ensure smooth and efficient system performance.

To make it easy to run programs from the command line, you can add a directory or program to the Windows PATH. Here is how to do it.

Windows has several built-in environment variables responsible for several different features and makes your life a tad bit easier. One of the most popular and useful Windows Variables is the PATH variable. The PATH variable allows you to add directories of executables so that it is easy to use them via the command line.

Generally, you don’t have to use the command line much in Windows. However, some programs may require or function better when using them via the command line. For example, FFMPG is a command-line tool. As such, adding FFMPEG to Windows PATH will make it easy to use the FFMPEG tool to download streaming videos. Similarly, if you use a specific application or program from the command line, you can add that executable’s directory to the Windows PATH. That way, you don’t have to open the Command Prompt or PowerShell window in the executable folder. Instead, you can use the program command directly as the path is already added to the Windows PATH, and the operating system knows where to look.

So, without delay, let me show you how to add a directory or a program to Windows PATH in Windows 10 and 11.

What is the PATH variable in Windows?

PATH is one of the system variables in Windows. The primary function of PATH is to let Windows know where to look for a program when running it from the command line. By default, most system programs are added to the PATH variable. That is why you don’t have to specify the absolute program path or open the command line window in the program directory while running a command related to system applications.

You will also find the PATH variable in other operating systems like Linux and macOS.

Can I edit the PATH variable?

Yes. You can edit the Windows PATH variable from the Environment Variables screen.

There are two kinds of PATH variables in Windows. i.e., User PATH variable and System PATH variable. As you can guess, anything thing added to the User PATH variable is only applicable to your user account. To apply the path system-wide (all users), you must add the directory or program to the System PATH variable.

To add to PATH in Windows, we need to open the Environment Variables tool. Here is how.

  1. Press the Start key on your keyboard.
  2. Search and open “Edit the system environment variables.”
  3. Go to the “Advanced” tab.
  4. Click the “Environment variables” button.
  5. Select the “Path” variable under “User variables” or “System variables.”
  6. Click the “Edit” button.
  7. Press the “New” button.
  8. Type the full directory path of the program.
  9. Press “Enter” to confirm the path.
  10. Click “Ok.”
  11. Press the “Ok” button in the Environment Variables window.
  12. Click “Ok” in the System Variables window.

Detailed steps:

First, we need to open the Environment Variables tool. To do that, search for “Edit the system environment variables” and click on the result. Here, make sure you are in the “Advanced” tab, and click on the “Environment Variables” button.

open environment variables

The above action will open the “Environment Variables” window. Select the “Path” variable under the “User Variables” or “System Variables” section. To limit the path to your user account, select the Path variable under the User Variables section. To apply the path to all users. i.e., system-wide, select the Path variable under the System Variables section. I’m choosing the Path variable under the User Variables section.

After selecting the Path variable, click on the “Edit” button under that section.

edit Windows path

Now, click the “New” button to add a new path to Windows PATH.

add directory or program to Windows path variable

Type the full path of the executable directory and click the “Ok” button. For example, suppose the full executable path is “C:\users\windowsloop\app\program.exe,” you need to type “C:\users\windowsloop\app\” in the blank field. Next, click the “Ok” button to save the changes.

Click “Ok” in the Environment Variables section.

Press the “Ok” button in the System Properties window.

That is it. You have successfully added a directory or program to Windows PATH. From now on, you can start using that program directly in any command-line tool.

Important note: After adding a directory or program to Windows PATH, you must close and re-open the command line tools. Otherwise, they might not recognize the changes in the PATH variable.

I hope that helps.

If you are stuck or need some help, comment below, and I will try to help as much as possible.

The PATH environment variable is an important part of the Windows operating system that allows the system to locate executable files. By adding a folder to the PATH, you can run executables from any location without having to specify the full path of the file. In this tutorial, we will show you how to add a folder to the PATH environment variable in Windows 10 using screenshots.

Method 1: Adding a Folder to the Path Environment Variable using System Properties

  1. Open the Start menu and search for «System Properties». Click on the «Edit the system environment variables» option.

Step 1

  1. In the System Properties window, click on the «Environment Variables» button.

Step 2

  1. Under «System Variables», scroll down and find «Path». Select it and click on the «Edit» button.

Step 3

  1. Click on the «New» button and enter the path of the folder you want to add to the Path environment variable. Click «OK» to close all windows.

Step 4

  1. Open a new command prompt window and type «echo %PATH%». You should see the new folder added to the Path environment variable.

Step 5

That’s it! You have successfully added a folder to the Path environment variable using System Properties in Windows 10.

REM Example code to add a folder to the Path environment variable using batch script
setx PATH "%PATH%;C:\path\to\folder"
$oldPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
$newPath = $oldPath + ";C:\path\to\folder"
[Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
import os
old_path = os.environ["PATH"]
new_path = old_path + ";C:\\path\\to\\folder"
os.environ["PATH"] = new_path
// Example code to add a folder to the Path environment variable using Java
String pathToAdd = "C:\\path\\to\\folder";
String oldPath = System.getenv("PATH");
String newPath = oldPath + ";" + pathToAdd;
System.setProperty("PATH", newPath);
// Example code to add a folder to the Path environment variable using C#
string pathToAdd = @"C:\path\to\folder";
string oldPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
string newPath = oldPath + ";" + pathToAdd;
Environment.SetEnvironmentVariable("PATH", newPath, EnvironmentVariableTarget.Machine);

Method 2: Adding a Folder to the Path Environment Variable using the Command Prompt

In Windows, the Path environment variable is a system variable that specifies the directories that command prompt searches for executable files. By adding a folder to the Path environment variable, you can run executable files located in that folder from any directory in the command prompt.

Here are the steps to add a folder to the Path environment variable using the Command Prompt:

  1. Open the Command Prompt by pressing Win + R and typing cmd in the Run dialog box.

  2. Type echo %PATH% and press Enter to see the current Path environment variable.

  3. Navigate to the folder you want to add to the Path environment variable using the cd command. For example, if you want to add the folder C:\Program Files\Python38 to the Path environment variable, type cd C:\Program Files\Python38 and press Enter.

  4. Type setx PATH "%PATH%;%CD%" and press Enter to add the current directory to the Path environment variable.

  5. Verify that the folder has been added to the Path environment variable by typing echo %PATH% and pressing Enter.

Here’s what each step does:

  1. Opens the Command Prompt.

  2. Displays the current Path environment variable.

  3. Navigates to the folder you want to add to the Path environment variable.

  4. Adds the current directory to the Path environment variable using the setx command. The %CD% variable is used to get the current directory.

  5. Verifies that the folder has been added to the Path environment variable.

That’s it! You have successfully added a folder to the Path environment variable in Windows 10 using the Command Prompt.

Adding a Folder to the Path Environment Variable using Command Prompt

  • Windows headers require the default packing option changing this can lead to memory corruption
  • Windows get genuine kit windows pro
  • Windows has encountered a problem communicating with a device connected to your computer 0xc00000e9
  • Windows hdr color что это
  • Windows generate ssh key for gitlab