Настройка переменных среды Windows может помочь сократить время, необходимое для набора команд в командной строке или, если вы часто пишете скрипты для собственных задач, сделать их более читаемыми. В большинстве случаев обычные пользователи добавляют записи в системную переменную среды PATH, хотя бывают и другие задачи.
В этой пошаговой инструкции базовая информация о том, как открыть переменные среды Windows 11 и Windows 10, создать или отредактировать их.
Что такое переменные среды
Переменные среды в Windows — записи о расположении системных папок, свойствах системы и другие, которые доступны для любой программы или скрипта.
Одна из наиболее часто используемых переменных среды — PATH, указывающая на папки, в которых выполняется поиск файлов, вызываемых в командной строке, терминале Windows, файле bat или из других источников. В качестве примера её назначения:
- Если вы откроете командную строку (или диалоговое окно «Выполнить»), введёте regedit и нажмете Enter — вы сможете запустить редактор реестра, не указывая полный путь к файлу regedit.exe, поскольку путь C:\Windows добавлен в переменную среды Path.
- Если же тем же образом в командной строке написать имя программы, путь к которой не добавлен в Path (chrome.exe, adb.exe, pip и другие), вы получите сообщение «Не является внутренней или внешней командой, исполняемой программой или пакетным файлом».
Если предположить, что вы часто используете команды adb.exe (например, для установки приложений Android в Windows 11), pip install (для установки пакетов Python) или любые другие то для того, чтобы не писать каждый раз полный путь к этим файлам, имеет смысл добавить эти пути в переменные среды.
Также вы можете добавлять и иные переменные среды (не обязательно содержащие пути), а в дальнейшем получать и использовать их значения в сценариях BAT (командной строки) или PowerShell. Пример получения и отображения значения системной переменной PATH для обоих случаев:
echo %PATH% echo $Env:PATH
Получить список всех переменных среды в командной строке и PowerShell соответственно можно следующими командами:
set ls env:
Редактирование переменных среды Windows 11/10
Прежде чем приступать, учтите: изменение системных переменных среды по умолчанию может привести к проблемам в работе системы, не удаляйте уже имеющиеся переменные среды. Возможно, имеет смысл создать точку восстановления системы, если вы не уверены в своих действиях.
- Чтобы открыть переменные среды Windows вы можете использовать поиск в панели задач (начните вводить «Переменных» и откройте пункт «Изменение системных переменных среды») или нажать клавиши Win+R на клавиатуре, ввести sysdm.cpl и нажать Enter.
- На вкладке «Дополнительно» нажмите кнопку «Переменные среды…»
- В разделе «Переменные среды пользователя» (если требуется изменение только для текущего пользователя) или «Системные переменные» выберите переменную, которую нужно изменить и нажмите «Изменить» (обычно требуется именно это), либо, если необходимо создать новую переменную — нажмите кнопку «Создать». В моем примере — добавляем свои пути в системную переменную Path (выбираем эту переменную и нажимаем «Изменить»).
- Для добавления нового значения (пути) в системную переменную в следующем окне можно нажать кнопку «Создать», либо просто дважды кликнуть по первой пустой строке, затем — ввести нужный путь к папке, содержащей нужные нам исполняемые файлы.
- Также вы можете использовать кнопку «Изменить текст», в этом случае окно изменения системной переменной откроется в ином виде: имя переменной, а ниже — её значение. В случае указания путей значение будет представлять собой все пути, хранящиеся в переменной, разделенные знаком «точка с запятой».
- При создании новой переменной среды окно будет тем же, что и в 5-м шаге: необходимо будет указать имя системной переменной в верхнем поле, а её значение — в нижнем.
После создания или изменения переменной среды и сохранения сделанных настроек, переменная или обновленные значения сразу становятся доступны для текущего пользователя или в системе в целом в зависимости от того, какие именно переменные редактировались или создавались. Также есть методы добавления переменных среды в командной строке или PowerShell, подробнее в статье: Как добавить путь в переменную среды PATH
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.
-
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.
-
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
-
This button is near the bottom of the window, below the «Startup and Recovery» section.
-
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.
-
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.
-
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.
-
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.
-
Keep clicking OK until you’ve closed out of System Properties completely.
-
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 ';'.
Advertisement
-
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.
-
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.
-
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.
-
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.
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 112,294 times.
Is this article up to date?
Introduction
In this article, we will see how we can create and set up path environment variables in Windows 11.
Windows Environment Variables
The Environment Variable is a variable that the computer creates and maintains automatically. It assists the system in determining where to install files, locate programs, and check for user and system preferences. It may also be accessed from anywhere on the computer by graphical and command-line tools. It is required to set up the environment variables so that the system knows the executable file that it needs to run on a given command.
Windows Path Variable
The PATH variable is nothing more than a directory of your computer’s applications and instructions. The PATH variable must include the address of any new program on your computer that you want to start through the command-line interface. As part of the process, Windows looks for the address for a certain command. When you send a command from the command line, Windows initially searches for it in the current directory. If it cannot be found in the current directory, the operating system checks for the address in the PATH variable.
Check Environment Variables
Use the following command to check the environment variables set on your PC.
echo %Environment Variable name%
To check the Path environment variable I will use «echo %Path%»
Setup Path Environment Variable
We require permission from the system administrator and privileges to utilize and set the environment variables. As a result, you must notify the system administrator and request their assistance if you are not one.
Step 1. Open the Setting using any of the following ways
- Press Windows+R, type «sysdm.cpl» and press «Ok».
- Press Window+I
- Press Windows+X, select «System».
- Press Windows+S, search for «System».
Note. You can skip steps 1 to 3 and directly open «System Properties» by pressing Windows+S to open the search menu and typing «environment», and press open.
Step 2. Under System, click on «About».
Step 3. Click on «Advanced system settings».
Step 4. Click «Environment Variables…».
Step 5. The environment variables panel shows up on the screen. You can observe two types of variables
- User Variables: Use them when you wish to change the environment variables for the current or specific user.
- System Variables: Use them when you want the system-wide changes.
I want to change the path variable system-wide, hence I will double-click on the highlighted row.
Step 6. Click the New button to add new paths or edit to modify the existing path. Delete will delete a path.
Press «OK» to save the changes.
If you already know the path, just write it in or copy and paste it. You may simply select Browse and then go to the route you wish to add in the System path variables.
To Create a New Environment Variable
Sometimes you may need to create a new environment variable, so for that, follow steps 1 to 4.
After that, click on «New» to open the «New System Variable» popup.
Add «Variable Name». You may choose whatever name you want.
Using «Browse Directory», you can select a directory. Press OK to select the desired folder.
Using «Browse Directory», you can select a particular file. Press OK to select the desired file.
Conclusion
In this article, we discussed how we can manage path environment variables on Windows 11.
Visit C# Corner to find answers to more such questions.
Why PATH Variables Matter So Much
Ever wondered why some programs run perfectly fine without specifying their full location, while others need a complete path to execute? The magic behind this is something called the PATH environment variable. This might sound like tech jargon, but it’s actually pretty straightforward. Basically, the PATH variable is a list of directories that Windows searches when you try to run a command or program. If the executable is in one of these directories, you can run it without typing the full path. So, let’s dive into what this really means and why it’s so important.
Imagine trying to find a book in a huge library without any organization. It’d be a nightmare, right? The PATH variable is like the library’s organizational system. It tells Windows exactly where to look for the programs you want to run, making everything faster and more efficient.
Think about it: you’ve got a bunch of apps and programs installed on your computer, and each one might have its own set of executable files. The PATH variable lets Windows know where to find these files quickly. It’s like having a map that points directly to where each program is stored. Pretty handy, huh?
And here’s the kicker: the PATH variable isn’t just for system-wide settings. You can customize it for individual users too. This means you can set up different environments for different users on the same computer. For example, a developer might need access to specific tools that a regular user doesn’t.
So, why does this matter? Well, it makes your computer run more smoothly and helps you avoid those annoying errors when a program can’t find the files it needs. Plus, it’s a great way to keep your system organized and efficient.
The way I see it (but I could be wrong), understanding PATH variables can make a big difference in how well your computer performs. And the good news is, you don’t need to be a tech genius to figure it out. With a bit of know-how, you can set up your PATH variable like a pro.
Before we move on, here’s a quick fun fact: did you know that the PATH variable has been around since the early days of computing? It’s one of those fundamental concepts that has stood the test of time. Anyway, let’s get into the details of how to actually set and edit these variables.
Setting Up PATH Variables in Windows
So, you want to set up or edit your PATH variable in Windows? Great! Let’s walk through the steps. It’s actually pretty simple once you know what you’re doing.
The easiest way to edit your PATH variable is through the Windows Settings menu. Here’s how you do it:
- Open the Search menu on the Taskbar and type ‘Settings’. Click on it to open.
- In the Settings panel, click on ‘System’ from the left menu.
- Go to ‘About’ and then click on ‘Advanced System Settings’. This opens the System Properties dialog box.
- In the System Properties window, click on the ‘Advanced’ tab and then click on the ‘Environment Variables’ button at the bottom-right.
- This opens the Environment Variables panel. You’ll see two sections: System variables and User variables. Choose the one that fits your needs and select ‘PATH’ from the list.
- Click on the ‘Edit’ button to modify the existing paths.
You can now add, edit, or delete paths as needed. Just remember to be careful, because messing up the PATH variable can cause some serious issues with your system. If you’re unsure about a path, you can use the ‘Browse’ option to search for it.
And that’s it! Once you’re done, click ‘OK’ to save your changes. Your new PATH variable is now set up.
Editing PATH Variables without Admin Rights
What if you don’t have admin rights on your computer? No problem. You can still edit the PATH variable for your user account through the Control Panel. Here’s how:
- Open the Control Panel and select to view as ‘Small icons’.
- Click on ‘User Accounts’.
- On the left, click on ‘Change my environment variables’.
- This opens the Environment Variables dialog box, but you’ll only be able to edit User variables, not System variables.
This method is great for making changes that only affect your user account. It’s a bit more limited, but it gets the job done.
Using Command Prompt
If you’re more comfortable with the command line, you can also edit the PATH variable using the Command Prompt. Here’s how:
- Search for ‘CMD’ on the Taskbar and run it as an administrator.
- Enter the command ‘setx PATH «%PATH%;C:\Your\New\Path»‘. This appends the new path to your existing PATH variable.
- To remove a path, you can use the ‘setx’ command with the ‘/M’ flag to modify the system PATH variable.
Using the Command Prompt can be a bit trickier, but it’s a powerful tool once you get the hang of it. Just make sure to double-check your commands before hitting enter.
Common PATH Variable Issues and How to Fix Them
Even with the best intentions, things can go wrong when editing the PATH variable. Here are some common issues and how to fix them:
PATH Too Long
One of the most common problems is the PATH variable becoming too long. Windows has a limit on the length of the PATH variable, and if you exceed it, you’ll run into issues. The fix? Clean up your PATH variable by removing any unnecessary or duplicate entries. You can also shorten the paths by using shorter directory names.
Incorrect Paths
Another common issue is having incorrect paths in your PATH variable. This can happen if you mistype a path or if a directory has been moved or deleted. The solution is to carefully check each path and make sure it’s correct. You can use the ‘Browse’ option in the Environment Variables dialog box to find the correct path.
Conflicting Paths
Sometimes, you might have conflicting paths in your PATH variable. This can cause programs to behave unexpectedly or not run at all. The best way to avoid this is to keep your PATH variable organized and only include the paths you actually need. If you suspect a conflict, try temporarily removing paths one by one to see if the issue resolves.
Advanced Tips for Managing PATH Variables
Once you’ve got the basics down, there are a few advanced tips that can help you manage your PATH variable like a pro.
Using Batch Scripts
If you find yourself frequently editing the PATH variable, you might want to consider using batch scripts. A batch script is a simple text file with a .bat extension that contains a series of commands. You can use a batch script to automate the process of adding or removing paths from your PATH variable. Here’s an example of a batch script that adds a new path:
@echo off
setx PATH "%PATH%;C:\Your\New\Path"
echo PATH variable updated.
To use this script, just save it as a .bat file and run it. The script will automatically update your PATH variable with the new path.
Environment Variable Editor Tools
There are also third-party tools available that can make managing your PATH variable even easier. Tools like Rapid Environment Editor and Path Editor offer user-friendly interfaces and advanced features for editing environment variables. These tools can be especially helpful if you need to manage PATH variables on multiple computers or for multiple users.
Backing Up Your PATH Variable
Before making any changes to your PATH variable, it’s a good idea to back it up. This way, if something goes wrong, you can easily restore your original settings. To back up your PATH variable, simply copy the current value to a text file and save it somewhere safe. If you need to restore it, you can just copy the value back into the PATH variable.
What’s Next?
So, there you have it, a comprehensive guide to setting up and managing PATH environment variables in Windows. You might be wondering, what’s next? Well, once you’ve mastered PATH variables, you can start exploring other environment variables and see how they can help you customize your system even further. There’s always more to learn when it comes to computers, and every new skill you pick up makes you that much more efficient and effective.
And remember, if you ever run into trouble, don’t hesitate to ask for help. There are plenty of resources available online, and chances are, someone else has run into the same issue before. The tech community is full of helpful people who are more than willing to share their knowledge and expertise.
So go ahead, dive in, and start experimenting with your PATH variable. You might be surprised at how much of a difference it can make in your daily computing life. And who knows? You might even discover a new passion for tinkering with your system settings. The possibilities are endless, and the journey is always rewarding.
FAQ
- What happens if I mess up my PATH variable?
- If you mess up your PATH variable, some programs might not run correctly, or you might see errors when trying to execute commands. The best thing to do is restore your PATH variable from a backup or carefully edit it to fix any issues.
- Can I have multiple paths in my PATH variable?
- Yes, you can have multiple paths in your PATH variable. They should be separated by semicolons (;). Just make sure not to exceed the length limit.
- How do I know if my PATH variable is too long?
- If your PATH variable is too long, you might see an error message when trying to save it, or some programs might not run correctly. To fix this, remove any unnecessary or duplicate entries.
- What is the difference between System and User variables?
- System variables apply to all users on the computer, while User variables apply only to the specific user account. System variables are useful for settings that need to be consistent across all users, while User variables are good for customizing individual user environments.
- Can I use the Command Prompt to edit System variables?
- Yes, you can use the Command Prompt to edit System variables, but you need to run it as an administrator and use the ‘/M’ flag with the ‘setx’ command to modify the system PATH variable.
- Is it safe to edit the PATH variable?
- Editing the PATH variable is generally safe as long as you know what you’re doing. Always back up your current PATH variable before making changes, and be careful to avoid typos or incorrect paths. If you’re unsure, it’s a good idea to consult a more experienced user or look up guides online.
Readers help support Windows Report. We may get a commission if you buy through our links.
Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more
The Command Prompt tool is the last remnant of DOS (a former command-based operating system) preserved in Windows. You can open software and run handy tools, such as the System File Checker, with it.
For example, you can run SFC by entering sfc /scannow without specifying any path. To open third-party software in Windows 10, you usually need to input an entire directory in the Command Prompt.
What is the path environment variable in Windows?
The Edit environment variable window enables you to add new paths to third-party software to open the programs without entering their complete directories in the Command Prompt.
The path environment variable tells your system where to find the SFC, but not the software. Moreover, this variable could be a handy setting for those who often use the Command Prompt.
Microsoft even replaced the Edit System Variable dialog in earlier Windows platforms with a new Edit environment variable path window in Windows 10.
Users can edit this system path variable, and we will show you how to do this in the guide below.
-
1. Press the Windows key on your keyboard or the Start button on your taskbar to open the search box.
-
2. In the Windows search box, type advanced system settings and click on the result.
-
3. When the System properties window opens, select View advanced system settings.
-
4. Press the Environment Variables button to open the window shown below.
-
5. You need to select the Path in the System variables box. Selecting the Path and pressing the Edit button opens the window shown directly below.
-
6. The Edit environment variable window above includes the following path:
C:\Windows\system32
This is where the System File Checker tool is. To add your own path, press the New button.
-
7. Enter C: in the empty space and press the Browse button to select a folder (If you don’t enter something in the space for the new path, your selected folder directory replaces the path listed above it).
-
8. Select a folder that includes third-party software in the Browse for Folder window. For example, we selected a folder that includes Firefox.
-
9. Press the OK button on the Browse for Folder window to confirm the selection (The Edit environment variable window will include your selected path as in the snapshot below).
-
10. Click the OK button on the Edit environment variable window to close it.
-
11. Press the OK buttons on the Environment Variables and System Properties windows to close them.
-
12. Re-open the Windows search box and type cmd in it, then right-click on the result and select Run as Administrator, to open the app as below.
-
13. Now you can open the software path you added to the Edit environment variable window by entering its executable.
For example, if you added Firefox’s path to it you can open that browser by entering Firefox in the Command Prompt.
How can I edit the path on Windows 10?
The easiest way to edit the path variable in Windows 10 is through the View advanced system setting. There you can add, edit, or delete a path variable.
After that, you can set the path that’s of interest to you and modify it in any way you want.
- How to save text from the Command Prompt in Windows 10
- How to Fix Opera Browser if It Fails to Install or Download
- 10 Ways to Fix File Explorer Problems in Windows 10/11
- 16 Ways To Stop Firefox From Using Too Much Memory in 2022
- Windows Explorer stops when copying files? Fix it like a pro
A program’s executable doesn’t always match the exact software title. For example, we found that Opera’s executable was Launcher. As such, check the software’s executable title in File Explorer and then enter that in the Command Prompt.
You no longer need to enter C:\folder\sub-folder\sub-folder software title to open a program. This certainly comes in handy if you’re unsure of the software’s path.
This is a fairly simple process, and after following the steps above, setting, editing, or changing the path environment variable in Windows 10 should be more or less a formality.
If you have any other questions about the process, please leave them in the comments section below.
Matthew Adams
Windows Hardware Expert
Matthew is a freelancer who has produced a variety of articles on various topics related to technology. His main focus is the Windows OS and all the things surrounding it.
He is passionate about the tech world, always staying up-to-date with the latest and greatest. With an analytical view, he likes problem-solving, focusing on errors and their causes.
In his free time, he likes to read and write about history and tries to always develop new skills.