- How to set the path and environment variables in Windows
- Setting the path and variables in Windows 10
- Setting the path and variables in Windows 8
- Setting the path and variables in Windows Vista and Windows 7
- Setting the path and variables in Windows 2000 and Windows XP
- What is the default Windows %PATH%?
- Setting path in the MS-DOS and Windows command line
- Как отредактировать PATH в Windows 7, 8 и Windows 10?
- Что такое PATH система Windows?
- Как добавить папку в PATH?
- Path в операционной системе Windows 7 и Windows 8
- Path в операционной системе Windows 10
- Системная переменная окружения PATH в Windows
- Для чего используется
- Пример
- Добавить директорию в PATH
- Изучить содержимое PATH
- Ошибки
- -bash: syntax error near unexpected token `(‘
- Postgesql
- Похожие статьи:
- How to modify the PATH variable definitely through the command line in Windows
- 2 Answers 2
How to set the path and environment variables in Windows
Setting the path and environment variables will differ depending on the version of Windows you have on your computer. Choose a link below for your version of Windows.
Administrator privileges are usually required to modify the path and environment variables.
Setting the path and variables in Windows 10
- From the desktop, right-click the very bottom-left corner of the screen to get the Power User Task Menu.
- From the Power User Task Menu, click System.
- In the Settings window, scroll down to the Related settings section and click the System info link.
- In the System window, click the Advanced system settings link in the left navigation pane.
- In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
- 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.
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 variable value.
To view and set the path in the Windows command line, use the path command.
Setting the path and variables in Windows 8
- From the desktop, right-click the very bottom-left corner of the screen to get the Power User Task Menu.
- From the Power User Task Menu, click System.
- Click the Advanced System Settings link in the left column.
- In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
- 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.
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 variable value.
To view and set the path in the Windows command line, use the path command.
Setting the path and variables in Windows Vista and Windows 7
- From 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.
- Click the Advanced System Settings link in the left column.
- In the System Properties window, click the Advanced tab, then click the Environment Variablesbutton near the bottom of that tab.
- 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.
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 Variable value.
To view and set the path in the Windows command line, use the path command.
Setting the path and variables in Windows 2000 and Windows XP
The path is now managed by Windows 2000 and Windows XP and not the autoexec.bat or autoexec.nt files, as was done with earlier versions of Windows. To change the system environment variables, follow the steps below.
- 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.
- In the System Propertieswindow, click the Advancedtab.
- In the Advanced section, click the Environment Variablesbutton.
- 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.
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 Variable value.
To view and set the path in 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.
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 in the Windows command line, use the path command.
Как отредактировать PATH в Windows 7, 8 и Windows 10?
Как запустить программу из командной строки не переходя каждый раз в папку с программой?! Как запускать сторонние программы так, как, например, программу IPCONFIG, которая не требует перехода в папку?
Что такое PATH система Windows?
Если вы скачали программу командной строки, например ADB (Android Debuggin Bridge), то вы не сможете запустить ее просто вписав adb в командной строке, как вы всегда поступали с системными командами Windows (IPCONFIG, NETSTAT и т.п.). Вместо этого вы должны будете указать командную строку содержащую полный путь к exe-файлу.
Это достаточно сложно писать в командной строке без ошибок, тем более, если вам приходится делать это достаточно часто.
PATH система Windows сообщает вашей операционной системе каталоги, в которых следует искать исполняемые файлы. Например ранее упоминаемая программа ipconfig.exe расположена в каталоге C:\Windows\System32, который в свою очередь уже добавлен в PATH Windows. При вводе команды ipconfig система обыщет все папки из PATH на наличие файла ipconfig.exe и запустит его выполнение.
Если вы хотите то же удобство с программой (в нашем примере это ADB), то приложение ADB необходимо добавить в PATH Windows и после этого для запуска достаточно будет вписать в командную строку:
Больше ничего впечатывать не придется.
Как добавить папку в PATH?
В Windows 7, 8 и Windows 10 попасть в настройки PATH можно так: Панель управления / Система / Дополнительные переменные среды.
Далее перейти в «Переменные среды».
В окне «Переменные среды» обратите внимание на переменную с именем Path. Выберите ее и нажмите «Изменить..»
Дальнейшие действия одинаковы в Windows 7 и 8, но иные, облегченные, в Windows 10.
Path в операционной системе Windows 7 и Windows 8
В этих системах переменная Path является не более, чем длинной строкой текста с адресами каталогов системы. В этот текст мы добавим каталог и с нашей программой ADB.
Для того, чтобы добавить запись с путем к исполняемому файлу в Windows 7 и 8 к тексту нужно добавить путь, которому предшествует точка с запятой, разделяющая различные записи. Например так:
Добавлять такой путь в текст path нужно только в конец строки.
После ввода нажмите ОК. Все, мы добавили каталог в patch Windows 7 и 8.
Path в операционной системе Windows 10
В операционной системе Windows 10 этот процесс проще и менее запутанный. После нажатия кнопки «Изменить…» откроется новое диалоговое окно с расположенными в отдельных строках путях path.
Это улучшение позволяет проще и нагляднее видеть имеющиеся пути path и облегчает добавить новые пути.
Для добавления нового пути в переменную path Windows 10 нужно нажать «Новый», добавить путь C:\Android\platform-tools и нажать ОК.
Новая запись появится в низу списка.
Теперь запуск Android Debug Bridge доступен из любого раздела командной строкой без ввода полного пути к исполняемому файлу.
Системная переменная окружения PATH в Windows
Если Вам нужно настроить PATH в Linux — перейдите сюда
Для чего используется | |
Пример | |
Добавить директорию в PATH | |
Изучить содержимое PATH | |
Ошибки | |
Postgesql |
Для чего используется
Когда Вы выполняете какую-либо команду в консоли, система ищет соответствие между названием этой команды и программой, которую можно выполнить.
Искать по всему жёсткому диску было бы слишком долго, поэтому поиск осуществляется только по некоторым директориям.
Список этих особых директорий хранится в системной переменной PATH.
Пример
Предположим, что возникла необходимость запускать какую-то программу, например Firefox , непосредственно из командной строки.
Без предварительной подготовки ввод Firefox в консоль выдаст ошибку.
‘firefox’ is not recognized as an internal or external command, operable program or batch file.
Чтобы решить эту проблему нужно добавить директорию с испоняемым файлом firefox в PATH
Добавить директорию в PATH
Быстрый способ перейти к редактированию PATH — нажать клавишу Win и ввести в поиск env
Правый клик на Этот Компьютер (This PC) → Свойства (Properties)
Дополнительные параметры системы (Advanced system settings)
Дополнительно (Advanced) → Переменные среды (Environment Variables)
Если хотите менять для всей системы, то в окошке «Переменные среды» (System Variables) найдите строку PATH в блоке «Системные переменные» (System variables) выделите кликом и нажмите кнопку «Изменить. » (Edit. )
Если хотите менять только для своего пользователя, то делайте это в блоке «Переменные среды пользователя %USERNAME%» (User variables for %USERNAME%)
Создайте новый путь (New)
Введите адрес директории в которой лежит нужная программа. В нашем случае это
C:\Program Files (x86)\Mozilla Firefox
Перезапустите консоль или открываем новую и пишем там firefox.
Браузер должен запуститься.
Изучить содержимое PATH
В PowerShell достаточно выполнить
Name Value —- —— Path C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPo.
В cmd.exe посмотреть список переменных окружения можно выполнив команду set без параметров.
Выдача содержит системные переменные и переменные пользователя а также дополнительную информацию. Содержимое PATH выделено зелёным.
Ошибки
-bash: syntax error near unexpected token `(‘
Скорее всего Вы пытаетесь добавить в unix PATH адрес из Windows, c пробелами, скобками и так далее.
andrey@olegovich-10:/usr/share$ export PATH=/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath_target_1128437:$PATH
-bash: syntax error near unexpected token `(‘
Для решения этой проблемы Вам нужно экранировать пробелы и скобки. Если импортируется много путей и ввод очень длинный — немного проще записать PATH=$PATH:/путь , если Вам подходит запись в конец.
Также нужно помнить, что все лишние пробелы сломают импорт — для проверки можно сделать весь скрипт в одну строку в текстовом редакторе.
Также стоит помнить, что если Вы работаете в bash под Windows , то переменные окружения нужно задавать через Windows.
andrey@olegovich-10:/usr/share$ export PATH=$PATH:/mnt/c/Program\ Files\ \(x86\)/Common\ Files/Oracle/Java/javapath_target_1128437
Postgesql
Приведу пример для использования psql из bash под Windows — это может пригодиться если Вы хотите временно добавить путь к psql в PATH чтобы запустить Postrgres скрипт.
В моём случае psql.exe находится в папке C:\Program Files\PostgreSQL\12\bin
Похожие статьи:
Если остались вопросы — смело задавайте их в Telegram группе — aofeedchat либо воспользуйтесь поиском по сайту
Чтобы следить за выходом новых статей — подписывайтесь на Telegram канал aofeed
How to modify the PATH variable definitely through the command line in Windows
I would like to make a .bat file that would add some string at the end of the value of the Windows PATH variable. Warning, I want this change to be definitive, not working only for the current session.
Does somebody know of a way to do this ? As much as possible it should not be dependent on the version of Windows
2 Answers 2
Sorry for the long answer, but a short answer on your question is impossible.
First of all you should understand how environment variables works. There are some places in the registry like HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKEY_CURRENT_USER\Environment where the environment variables will be hold. On start-up the operation system reads this registry keys. Then one windows process creates another windows process. The parent process can give to the client process any set of environment variables. If the parent process doesn’t do this, the child process inherits environment variables of the parent processes.
To be able update environment variables of a running process with respect of WM_WININICHANGE or WM_SETTINGCHANGE messages. A windows application can interpret this messages and reread the current environment variables from the registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKEY_CURRENT_USER\Environment . So you can in general change registry values under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment or HKEY_CURRENT_USER\Environment and send
It would be much better to use SendMessageTimeout instead of SendMessage, but the idea will stay the same. The problem is that other processes must not wait for the message and do something. Most console application have no message loop and don’t do anything if you send such messages.
So it is important to understand that there is no simple way to update environment variables of all processes without restarting of the computer. You should have a clear understanding of this and reduce your question a little.