Windows cmd path command

PATH – отобразить или изменить пути поиска исполняемых файлов.

Команда PATH используется для указания или просмотра путей поиска исполняемых файлов. Пути поиска представляют собой строки, определяющие перечень каталогов файловой системы, в которых находятся исполняемые файлы (файлы с расширением .bat, .cmd, .exe, .vbs и т.п. ), разделенные точкой с запятой ; Например, C:\windows;C:\windows\system32 — определяет пути поиска C:\windows и C:\windows\system32 . Если вы в командной строке набираете program.exe без явного указания пути, то для запуска файла program.exe выполняется его поиск в текущем каталоге, и если он не найден, то в каталоге C:\windows , если и там не найден – в каталоге C:\windows\system32 . Если же исполняемый файл будет в обоих каталогах, то выполнится запуск из того, что определен ранее — C:\windows . Значение переменной среды PATH содержит пути поиска исполняемых файлов определенный на данный момент времени.

Формат командной строки:

PATH ; — очистить путь поиска используемых файлов, ограничив его текущим каталогом.

PATH [[диск:]путь[;. ][;] — установит ь пути поиска исполняемых файлов.

Команда PATH без параметров отображает текущий путь поиска. В командную строку допускается включение переменной %PATH% , задающей прежний путь поиска.

path /? — отобразить подсказку по использованию команды.

path — отобразить пути поиска исполняемых файлов.

path %PATH%;C:\Scripts — добавить путь C:\Scripts в конец существующего списка каталогов для поиска исполняемых файлов.

path C:\scripts;%PATH% — добавить путь C:\Scripts в начало существующего списка каталогов для поиска исполняемых файлов.

При выполнении команды PATH, значение передаваемых ей параметров не анализируется и воспринимается как обычная строка символов, поэтому, например, трижды выполнив команду path C:\scripts;%PATH% вы создадите 3 записи для пути C:\Scripts . Значение переменной PATH, измененное командой действует только на момент текущего сеанса командной строки. Для постоянного изменения системных и пользовательских переменных среды, в том числе, и путей поиска, используется команда SetX . В постоянно действующих путях поиска не стоит указывать каталоги сменных носителей (дискет, CD/DVD, карты памяти и т.п.)

path path

Задает путь к команде в переменной среды PATH, указывающий набор каталогов, используемых для поиска исполняемых файлов (exe). Sets the command path in the PATH environment variable, specifying the set of directories used to search for executable (.exe) files. При использовании без параметров эта команда отображает текущий путь к команде. If used without parameters, this command displays the current command path.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
[ :]

Указывает диск и каталог, который нужно задать в пути к команде. Specifies the drive and directory to set in the command path. Текущий каталог всегда ищется перед каталогами, указанными в пути к команде. The current directory is always searched before the directories specified in the command path. ; ; Разделяет каталоги в пути команды. Separates directories in the command path. При использовании без параметров ; очищает существующие пути к командам из переменной среды PATH и направляет Cmd.exe для поиска только в текущем каталоге. If used without other parameters, ; clears the existing command paths from the PATH environment variable and directs Cmd.exe to search only in the current directory. %PATH% Добавляет путь команды к существующему набору каталогов, перечисленных в переменной среды PATH. Appends the command path to the existing set of directories listed in the PATH environment variable. Если включить этот параметр, Cmd.exe заменит его значениями пути к командам, найденными в переменной среды PATH, что устраняет необходимость вручную вводить эти значения в командной строке. If you include this parameter, Cmd.exe replaces it with the command path values found in the PATH environment variable, eliminating the need to manually enter these values at the command prompt. /? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

Операционная система Windows выполняет поиск по расширениям имен файлов по умолчанию в следующем порядке приоритета: exe, com, bat и cmd. The Windows operating system searches using default file name extensions in the following order of precedence: .exe, .com, .bat, and .cmd. Это означает, что если вы ищете пакетный файл с именем, acct.bat, но у вас есть приложение с именем acct.exe в том же каталоге, необходимо включить расширение bat в командную строку. Which means if you’re looking for a batch file named, acct.bat, but have an app named acct.exe in the same directory, you must include the .bat extension at the command prompt.

Если два или более файлов в пути команды имеют одинаковое имя файла и расширение, эта команда сначала выполняет поиск указанного имени файла в текущем каталоге. If two or more files in the command path have the same file name and extension, this command first searches for the specified file name in the current directory. Затем он ищет каталоги в пути команды в том порядке, в котором они указаны в переменной среды PATH. Then, it searches the directories in the command path in the order that they’re listed in the PATH environment variable.

При помещении команды path в файл AUTOEXEC. NT операционная система Windows автоматически добавляет указанный путь поиска подсистемы MS-DOS при каждом входе в систему. If you place the path command in your Autoexec.nt file, the Windows operating system automatically appends the specified MS-DOS subsystem search path every time you log on to your computer. Cmd.exe не использует файл AUTOEXEC. NT. Cmd.exe does not use the Autoexec.nt file. При запуске из ярлыка Cmd.exe наследует переменные среды, заданные в Мой компьютер/свойствах/дополнительном/окружении. When started from a shortcut, Cmd.exe inherits the environment variables set in My Computer/Properties/Advanced/Environment.

Примеры Examples

Для поиска по путям к:\усер\таксес, б:\усер\инвест и б:\бин для внешних команд введите: To search the paths c:\user\taxes, b:\user\invest, and b:\bin for external commands, type:

Set path from command line

Users can run an executable from windows command prompt either by giving the absolute path of the file or just by the executable file name. In the latter case, Windows searches for the executable in a list of folders which is configured in environment variables. These environment variables are as below.

1. System path
2. User path

The values of these variables can be checked in system properties( Run sysdm.cpl from Run or computer properties). Initially user specific path environment variable will be empty. Users can add paths of the directories having executables to this variable. Administrators can modify the system path environment variable also.

How to set path from command line?

In Vista, Windows 7 and Windows 8 we can set path from command line using ‘setx’ command.

For example, to add c:\dir1\dir2 to the path variable, we can run the below command.

Alternative way is to use Windows resource kit tools ‘pathman.exe‘. Using this command we can even remove a directory from path variable. See download windows resource kit tools. This works for Windows 7 also.

Add directory to system path environment variable:

Open administrator command prompt
Run the below command

Remove path from system path environment variable:
Run the below command from elevated command prompt

Setting user path environment variable

For user environment varlables, admin privileges are not required. We can run the below command to add a directory to user path environment variable.

To remove a directory from user path, you can run the below command.

Default option is not allowed more than ‘2’ time(s)

You get this error if you have not enclosed ‘path’ in double quotes. See the below example for setting the path of firefox.

Now if you move %path% to be in the double quotes

Could a context entry be created for folders, perhaps an extended one… to add to path?

what about a multi-verb option, like copy as path?

hi, when i use setx at an administrator command line, it creates a USER variable, NOT the SYSTEM variable. What am i doing wrong? How do i change the SYSTEM path at command prompt? -thx

Johny Why
Answer: Try add the parameter /M

Hi, is there a way I can add an extra variable instead on deleting the currently one and put a new Variable on the Path.

I used the command setx /M “c:\Options”, and what it does is delete the current one and then puts that one there, all I want is to add the new variable to the current one. -thx

Nuno, pathman described above does exactly that. You can download the resource tools kit and get it.

setx path “%path%;C:\yourFolder”

To set path for java & javac, can I add the paths to PATH or do I need to create the environment variable JAVA_HOME. I don’t have this defined, but windows does not seem to be able to find java binaries on my system.

You can directly add the folder to PATH. No need to define JAVA_HOME. However, adding JAVA_HOME separately avoids cluttering and helps to easily understand what is added.

hello, can someone plz explain this result? After setting path, it did not change. This was run from an Administrator command-line:

C:\Windows\system32>setx path “C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;D:\Program Files (x86)\Microsoft VS Code\bin”

SUCCESS: Specified value was saved.

C:\Windows\system32>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;D:\Program Files (x86)\Microsoft VS Code\bin;D:\Program Files (x86)\metapad36;D:\Program Files (x86)\metapad36″ /M

Why won’t this work?

SET EPO = D:\Program Files (x86)\McAfee\ePolicy Orchestrator
PATH = %PATH%;%EPO%\jre\bin;%EPO%\apache2\bin

In windows 10 set path %path%; not working. it’s work like :
setx “%path%;C:\Program Files\CodeBlocks\MinGW\bin”

By unfortunately I deleted my system default path. How could I able to find my system path?

Unfortunately I deleted several files with unremembered path names. This article was useful

The following used to work for me when I am in MSDOS environment. Lately I get error messages such as INCLUDE not found. Why is this so?

Used to work
SET PLL =c:\CL5\PLL
SET PLT =c:\CL5\PLL
SET INCLUDE =c:\CL5\INCLUDE
SET PRG =c:\IMS\PRG
SET LIB =c:\CL5\LIB
SET OBJ =c:\CL5\OBJ
PATH =c:\IMS\EXE;\CL5\BIN;\CL5\NG;\CL5\PLL

pathman is one of many tools of the Windows Server 2003 Resource Kit Tools

Note: The Windows Server 2003 Resource Kit Tools are not supported on 64-bit platforms.

Huh.
When I did that on Windows 10 v1903, using setx, it replaced the USER scope paths with the SYSTEM scope paths.
Now I’m not sure what was in the old user path.
So, uh… Be careful out there.
And if anyone has a solution how to avoid that, please let me know
Thanks

Windows CMD: PATH Variable – Add To PATH – Echo PATH

PATH is an environment variable that specifies a set of directories, separated with semicolons ( ; ), where executable programs are located.

In this note i am showing how to print the contents of Windows PATH environment variable from the Windows command prompt.

I am also showing how to add a directory to Windows PATH permanently or for the current session only.

Cool Tip: List environment variables in Windows! Read More →

Echo Windows PATH Variable

Print the contents of the Windows PATH variable from cmd :

The above commands return all directories in Windows PATH environment variable on a single line separated with semicolons ( ; ) that is not very readable.

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

Cool Tip: Set environment variables in Windows! Read More →

Add To Windows PATH

Warning! This solution may be destructive as Windows truncates PATH to 1024 characters. Make a backup of PATH before any modifications.

Save the contents of the Windows PATH environment variable to C:\path-backup.txt file:

Set Windows PATH For The Current Session

Set Windows PATH variable for the current session:

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:

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

Info: To see the changes after running setx – open a new command prompt.

Windows cmd path command

Sets the command path in the PATH environment variable, specifying the set of directories used to search for executable (.exe) files. If used without parameters, this command displays the current command path.

Syntax

Parameters

Specifies the drive and directory to set in the command path. The current directory is always searched before the directories specified in the command path. ; Separates directories in the command path. If used without other parameters, ; clears the existing command paths from the PATH environment variable and directs Cmd.exe to search only in the current directory. %PATH% Appends the command path to the existing set of directories listed in the PATH environment variable. If you include this parameter, Cmd.exe replaces it with the command path values found in the PATH environment variable, eliminating the need to manually enter these values at the command prompt. /? Displays help at the command prompt.

Remarks

The Windows operating system searches using default file name extensions in the following order of precedence: .exe, .com, .bat, and .cmd. Which means if you’re looking for a batch file named, acct.bat, but have an app named acct.exe in the same directory, you must include the .bat extension at the command prompt.

If two or more files in the command path have the same file name and extension, this command first searches for the specified file name in the current directory. Then, it searches the directories in the command path in the order that they’re listed in the PATH environment variable.

If you place the path command in your Autoexec.nt file, the Windows operating system automatically appends the specified MS-DOS subsystem search path every time you log on to your computer. Cmd.exe does not use the Autoexec.nt file. When started from a shortcut, Cmd.exe inherits the environment variables set in My Computer/Properties/Advanced/Environment.

Examples

To search the paths c:\user\taxes, b:\user\invest, and b:\bin for external commands, type:

Читайте также:  Переустановка windows не удаляя данных
Оцените статью