Add exe to path windows

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

Указывает диск и каталог, который нужно задать в пути к команде. 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

Если два или более файлов в пути команды имеют одинаковое имя файла и расширение, эта команда сначала выполняет поиск указанного имени файла в текущем каталоге. 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:


20 Answers 20

You need to make sure that the exe is in a folder that’s on the PATH environment variable.

Windows 10, 8.1, 8

You can add the following registry key:

In this key, add the default string value containing the path to the exe file.

Another solution I personally prefer is using RapidEE for a smoother variable editing.

Rather than putting the executable into a directory on the path, you should create a batch file in a directory on the path that launches the program. This way you don’t separate the executable from its supporting files, and you don’t add other stuff in the same directory to the path unintentionally.

Such batch file can look like this:

Let’s say my exe is C:\Program Files\AzCopy\azcopy.exe

I can now simply type and use azcopy from any location from any shell inc command prompt, powershell, git bash etc

it’s amazing there’s no simple solution for such a simple task on windows, I created this little cmd script that you can use to define aliases on windows (instructions are at the file header itself):

this is pretty much the same approach used by tools like NPM or ruby gems to register global commands.

It is very simple and it won’t take more than 30 seconds.

For example the software called abc located in D:/Softwares/vlc/abc.exe Add the folder path of abc.exe to system environment variables.

Читайте также:  Asus eee pc x101h драйвера windows 7

now you can just open cmd prompt and you can launch the software from anywhere. to use abc.exe just type abc in the command line.

You may also permanently (after reboots) add to the Path variable this way:

Simple Bash-like aliases in Windows

To get global bash-like aliases in Windows for applications not added to the path automatically without manually adding each one to the path, here’s the cleanest solution I’ve come up with that does the least amount of changes to the system and has the most flexibility for later customization:

«Install» Your Aliases Path

Add Your Alias

Open in New Shell Window

Execute in Current Shell Window

Execute in Current Shell Window 2

If you don’t need the application to change the current working directory at all in order to operate, you can just add a symlink to the executable inside your aliases folder:

Add to the PATH, steps below (Windows 10):

Use a 1 line batch file in your install:

you may type the ‘exename’ in command-line and it’ll run it.

In order to make it work

Here is how to create a system environment variable from a python script:

It is important to run it with administrator privileges in order to make it work. To better understand the code, just read the comments on it.

Tested on Windows 10

You can find more information in the winreg documentation


Adding a directory to the PATH environment variable in Windows

I am trying to add C:\xampp\php to my system PATH environment variable in Windows.

I have already added it using the Environment Variables dialog box.

But when I type into my console:

it doesn’t show the new C:\xampp\php directory:

I have two questions:

18 Answers 18

This only modifies the registry. An existing process won’t use these values. A new process will do so if it is started after this change and doesn’t inherit the old environment from its parent.

You didn’t specify how you started the console session. The best way to ensure this is to exit the command shell and run it again. It should then inherit the updated PATH environment variable.

Option 1

After you change PATH with the GUI, close and re-open the console window.

Option 2

Execute this command in the command window you have open:

WARNING: This solution may be destructive to your PATH, and the stability of your system. As a side effect, it will merge your user and system PATH, and truncate PATH to 1024 characters. The effect of this command is irreversible. Make a backup of PATH first. See the comments for more information.

Don’t blindly copy-and-paste this. Use with caution.

You can permanently add a path to PATH with the setx command:

You should run this command from an elevated command prompt.

If you only want to change it for the current session, use set.

You don’t need any set or setx command. Simply open the terminal and type:

This shows the current value of PATH variable. Now you want to add directory to it? Simply type:

If for any reason you want to clear the PATH variable (no paths at all or delete all paths in it), type:


Like Danial Wilson noted in comment below, it sets the path only in the current session. To set the path permanently, use setx but be aware, although that sets the path permanently, but not in the current session, so you have to start a new command line to see the changes. More information is here.

To check if an environmental variable exist or see its value, use the ECHO command:

I would use PowerShell instead!

To add a directory to PATH using PowerShell, do the following:

To set the variable for all users, machine-wide, the last line should be like:

In a PowerShell script, you might want to check for the presence of your C:\xampp\php before adding to PATH (in case it has been previously added). You can wrap it in an if conditional.

So putting it all together:

Better still, one could create a generic function. Just supply the directory you wish to add:

You could make things better by doing some polishing. For example, using Test-Path to confirm that your directory actually exists.

Safer SETX


The ss64 SETX page has some very good examples. Importantly it points to where the registry keys are for SETX vs SETX /M

Usage instructions

Append to User PATH

Append to System PATH

(It’s basically the same except with a different Key and the SETX /M modifier.)


Finally there’s potentially an improved version called SETENV recommended by the ss64 SETX page that splits out setting the user or system environment variables.

1. Not strictly true

Handy if you are already in the directory you want to add to PATH:

It works with the standard Windows cmd, but not in PowerShell.

Читайте также:  Windows live assistant sign in

To override already included executables;

Aside from all the answers, if you want a nice GUI tool to edit your Windows environment variables you can use Rapid Environment Editor.

Try it! It’s safe to use and is awesome!

It does things in an intuitive way. For example:

It shows results without the need to spawn a new cmd!

Regarding point 2 I’m using a simple batch file that is populating PATH or other environment variables for me. Therefore, there is no pollution of environment variables by default. This batch file is accessible from everywhere so I can type:

Checking the above suggestions on Windows 10 LTSB, and with a glimpse on the «help» outlines (that can be viewed when typing ‘command /?’ on the cmd), brought me to the conclusion that the PATH command changes the system environment variable Path values only for the current session, but after reboot all the values reset to their default- just as they were prior to using the PATH command.

On the other hand using the SETX command with administrative privileges is way more powerful. It changes those values for good (or at least until the next time this command is used or until next time those values are manually GUI manipulated. ).

The best SETX syntax usage that worked for me:

The PATH keyword that follows the SETX defines which set of values should be changed among the System Environment Variables possible values, and the %PATH% (the word PATH surrounded by the percent sign) inside the quotation marks, tells the OS to leave the existing PATH values as they are and add the following path (the one that follows the split sign ‘;’) to the existing values.


How to Add to Windows PATH Environment Variable

Works for Windows 10 or 7

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.

Читайте также:  Windows 10 автозапуск в реестре windows

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!

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications. Read Aseem’s Full Bio


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?

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.

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.

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

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.

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


Поделиться с друзьями
Советы экспертов и специалистов