How can you make a .exe file accessible from any location in the Windows command window? Is there some registry entry that has to be entered?
25 Answers
You need to make sure that the exe is in a folder that's on the PATH
environment variable.
You can do this by either installing it into a folder that's already on the PATH
or by adding your folder to the PATH
.
You can have your installer do this - but you may need to restart the machine to make sure it gets picked up.

- 134,786
- 31
- 255
- 325
-
38@KimGentes well that's a problem with the uninstaller. A good uninstaller should tidy up nicely. It doesn't make the answer wrong. – ChrisF Mar 06 '15 at 21:35
-
4I agree .. it's a problem with the installer. But since all installers do this to variables (they don't parse and extract portions of registry entries or ENV VARIABLES), it seems prudent to explain it. If one follows the directions exactly, they will always run into this issue, which means, the solution should probably always include that caveat. No install packages take care of installing and uninstalling sections of Registry entries or ENV variables that I know of, although please let me know if there is some I don't know of. – Kim Gentes Mar 06 '15 at 21:40
-
Instead of "installing" the environmental use a batch file with the SETX command: SETX PATH "C:\Windows" ----- and youre done. – Stavm Mar 10 '15 at 17:47
-
@polisha989 SETX has the same problems relative to an install as the other solutions-- you can add the folder just fine. But when it comes to uninstalling the changes (IE your path update), SETX can only possibly clear the entire path, it doesn't know how to reverse it's previous activity in a way that ensures it doesn't effect other changes to the PATH variable not related to its change. The important thing is to retain the FOLDER name added to PATH, and on uninstall remove ONLY what you have added at install. – Kim Gentes Mar 17 '15 at 22:59
-
3SETX is also dangerous because it has a much lower length limit than the PATH variable itself, and will truncate instead of failing. – Ben Voigt Oct 01 '15 at 17:37
-
If you have PowerShell open, you'll need to restart it to gain access to your exe after setting the path. – Corey P May 06 '20 at 14:44
-
3[Raymond Chen has covered why this is bad](https://devblogs.microsoft.com/oldnewthing/20110725-00/?p=10073): a) global solution to a local problem; b) PATH has a length limit you may reach; c) slows down all program starts due to larger HDD search space; d) hard to undo on uninstall. This is indeed exactly what App Paths were introduced for, though they only work with the START command. See Andreas Rejbrands answer below and use `START /WAIT /B your_exe` to run your program. – Krishty Sep 29 '20 at 06:42
-
I just wanted to point out that it's usually not necessary to reboot after an installer alters the path. This is because a WM_SETTINGCHANGE message is usually sent which updates explorer with the environment update. Thus any child of explorer will then generally get the new path. So, at most, restarting an app is generally required. This is also how the control panel applet works. – Benj Mar 03 '21 at 19:56
-
You have to restart the machine? You can't just refresh the environment variables? – wordsforthewise Feb 28 '23 at 16:59
-
1@wordsforthewise You *may* have to restart the machine. It all depends on how the installer has been written and things have come on in the 12 years since I wrote this answer. – ChrisF Feb 28 '23 at 17:02
Windows 10, 8.1, 8
Open start menu,
- Type
Edit environment variables
- Open the option
Edit the system environment variables
- Click
Environment variables...
button - There you see two boxes, in
System Variables
box findpath
variable - Click
Edit
- a window pops up, click
New
- Type the Directory path of your
.exe
orbatch
file ( Directory means exclude the file name from path) - Click
Ok
on all open windows andrestart your systemrestart the command prompt.

- 126
- 1
- 12

- 5,129
- 3
- 39
- 55
-
19This is the only answer that helped me. I would add that "restarting the system" isn't necessary. Simply restarting the cmd would suffice. – Joffrey Baratheon Feb 05 '18 at 23:35
-
6
-
put a .bat file with the commands you need (I use to run .py script into this) into a FOLDER, go in the variable environment setting, in the global settings choose path, then modify, then add the path to your .bat file (without the .bat file), close everything: done. – PythonProgrammi Jan 09 '21 at 08:55
-
For this to work, I also did what is described in [the answer provided by Ben Voigt in this thread](https://stackoverflow.com/a/4822618/7077264) – thymaro Feb 07 '21 at 11:28
-
If exe has long name, "C:\Windows\linkerd2-cli-edge-21.9.1-windows.exe" ; then you can rename it to linkerd.exe and add it's directory "C:\Program Files\Linkerd" and then use it as PS C:\Code> linkerd linkerd manages the Linkerd service mesh. Usage: linkerd [command] Available Commands: check Check the Linkerd installation for potential – Vinay Sep 03 '21 at 21:46
-
should we set the User Environrment `path` or the System Environment `path`? – JobaDiniz Oct 07 '22 at 17:37
-
1depends on the behavior you expect @JobaDiniz, setting in sys env will make it available to all users. – AmiNadimi Oct 18 '22 at 15:48
You can add the following registry key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\myexe.exe
In this key, add the default string value containing the path to the exe file.

- 105,602
- 8
- 282
- 384
-
1@sherdim: I highly doubt that. However, it has always worked with the `start` command, so you can type `start myexe` in a cmd.exe prompt. But `myexe` alone shouldn't work, I think (unless you are in the directory of `myexe` or that directory is in the `PATH` environment variable). – Andreas Rejbrand Sep 18 '18 at 11:30
-
1I simply make a small `myprog.cmd` file with the following content: `@START myprog.exe %*` This invokes the `App Paths` entry for `myprog.exe` and passes all command arguments. The file should be created somewhere accessible in `PATH` – Stavr00 Oct 02 '18 at 17:21
-
1@sherdim @andreas-rejbrand I can confirm this does not work on windows 10 if myexe is not in `PATH`. `start myexe` does work with this registry change, *without* adding myexe to `PATH`. – davenpcj May 07 '19 at 16:02
-
@davenpcj: Indeed. The registry key I mentioned is related to the Windows shell, not to the command prompt. So `start myapp` works, as well as Win+R `myapp`, but not a plain `myapp` in cmd.exe. – Andreas Rejbrand May 07 '19 at 19:24
-
2This key works to run from Explorer.exe, if you try from CMD.exe it is not found. – elpezganzo Apr 17 '20 at 19:23
-
@prampe: Yes, this is only for the Windows shell. It will not work on the command-line, unless you use the `start` command. – Andreas Rejbrand Apr 17 '20 at 20:19
-
1This should be the accepted answer because it’s in accordance with [Microsoft’s documentation](https://learn.microsoft.com/en-us/windows/win32/shell/app-registration). `START /WAIT /B your_program` runs programs like they were added to `PATH`, but without its quirks (having to handle length limits and undoing it on uninstall) and without its global side effects (slowing down every program call due to having to search yet another directory in `PATH`). [Obligatory Old New Thing article.](https://devblogs.microsoft.com/oldnewthing/20110725-00/?p=10073) – Krishty Sep 29 '20 at 06:54
You have to put your .exe
file's path into enviroment variable path. Go to "My computer -> properties -> advanced -> environment variables -> Path" and edit path by adding .exe
's directory into path.
Another solution I personally prefer is using RapidEE for a smoother variable editing.

- 46,442
- 10
- 75
- 103
-
More specifically, your `PATH` might look like this: `C:\Stuff;C:\Anotherthing` if your exe file is in `C:\MyNewPath` then you need to change `PATH` to `C:\Stuff;C:\Anotherthing;C:\MyNewPath` – Nick.Mc Aug 08 '23 at 01:10
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:
@echo off
start "" "C:\Program Files (x86)\Software\software.exe" %*

- 13,728
- 5
- 43
- 72

- 277,958
- 43
- 419
- 720
-
1Do you mind adding an example of such an batch-file - would be nice? – petermeissner Aug 13 '13 at 08:45
-
I feel like this is the best option, I didn't want to add too many stuff to path variable. I'll edit into this answer example of such batch file. – Dino Apr 14 '15 at 11:43
-
1The problem I'm having with this is it starts a new shell. I'm trying to get a cygwin binary to launch in the same shell, which it does if I reference it directly as `C:\cygwin\bin\grep.exe` – Johann Oct 01 '15 at 16:55
-
4@Johann: Take out the `start "" ` and just begin with the path to the executable. Also, for use in cygwin, you might want a cygwin shell script, or a symlink. Or a shell alias. – Ben Voigt Oct 01 '15 at 17:36
-
Perfect, thank you! I agree with your other options for within cygwin, but in this case I'm trying to use a cygwin binary from powershell. – Johann Oct 01 '15 at 19:27
-
-
Let's say my exe is C:\Program Files\AzCopy\azcopy.exe
Command/CMD/Batch
SET "PATH=C:\Program Files\AzCopy;%PATH%"
PowerShell
$env:path = $env:path + ";C:\Program Files\AzCopy"
I can now simply type and use azcopy
from any location from any shell inc command prompt, powershell, git bash etc

- 1,305
- 1
- 11
- 17
-
Does this remain permanent ? $env:path defaults back to it's original state once the prompt is closed https://codingbee.net/powershell/powershell-make-a-permanent-change-to-the-path-environment-variable – Vinay Sep 03 '21 at 21:49
-
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.
My Computer -> Click Properties -> Click Advanced system settings -> Click Environment Variables
Click on Ok.
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.

- 3,568
- 26
- 37
-
ah got it! I was adding a whole `variable` with `path` as value, instead I should have added just the path to `exe` under exiting `path`. Awesome! Thanks for visual cues! Kudos! – sud007 Aug 17 '22 at 13:16
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):
https://gist.github.com/benjamine/5992592
this is pretty much the same approach used by tools like NPM or ruby gems to register global commands.

- 4,099
- 1
- 30
- 31
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
mkdir c:\aliases
setx PATH "c:\aliases;%PATH%"
Add Your Alias
Open in New Shell Window
To start C:\path to\my program.exe
, passing in all arguments, opening it in a new window, create c:\aliases\my program.bat
file with the following contents(see NT Start Command for details on the start commmand):
@echo off
start "myprogram" /D "C:\path to\" /W "myprogram.exe" %*
Execute in Current Shell Window
To start C:\path to\my program.exe
, passing in all arguments, but running it in the same window (more like how bash operates) create c:\aliases\my program.bat
file with the following contents:
@echo off
pushd "C:\path to\"
"my program.exe" %*
popd
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:
cd c:\aliases\
mklink "my program.exe" "c:\path to\my program.exe"
-
`Setx` is a horrible suggestion which [breaks long PATH variables](https://superuser.com/q/387619/29943) – Ben Voigt Mar 03 '21 at 17:08
Add to the PATH, steps below (Windows 10):
- Type in search bar "environment..." and choose Edit the system environment variables which opens up the System Properties window
- Click the Environment Variables... button
- In the Environment Variables tab, double click the Path variable in the System variables section
- Add the path to the folder containing the .exe to the Path by double clicking on the empty line and paste the path.
- Click ok and exit. Open a new cmd prompt and hit the command from any folder and it should work.

- 2,126
- 28
- 21
You may also permanently (after reboots) add to the Path variable this way:
Right click My Computer -> Click Properties -> Click Advanced system settings -> Click Environment Variables
Reference: Change System/User Variables

- 154
- 2
- 16
-
https://www.windows-commandline.com/system-properties-windows-run-command/ – elpezganzo Apr 17 '20 at 22:29
- If you want to be able to run it inside cmd.exe or batch files you need to add the directory the .exe is in to the %path% variable (System or User)
- If you want to be able to run it in the Run dialog (Win+R) or any application that calls ShellExecute, adding your exe to the app paths key is enough (This is less error prone during install/uninstall and also does not clutter up the path variable)

- 97,548
- 12
- 110
- 164
Put it in the c:\windows directory or add your directory to the "path" in the environment-settings (windows-break - tab advanced)
regards, //t

- 6,644
- 8
- 46
- 69
-
Instead of placing custom executables into `C:\Windows`, one should rather add a custom directory to the `PATH` environment variable. – Roland Illig Oct 29 '16 at 01:49
-
In order to make it work
You need to modify the value of the environment variable with the name key Path
, you can add as many paths as you want separating them with ;
. The paths you give to it can't include the name of the executable file.
If you add a path to the variable Path
all the excecutable files inside it can be called from cmd or porweshell by writing their name without .exe
and these names are not case sensitive.
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
import winreg
# Create environment variable for call the program from shell, only works with compiled version
def environment_var(AppPath):
# Point to the registry key of the system environment variables
key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, r'System\CurrentControlSet\Control\Session Manager\Environment')
def add_var(path):
# Add the variable
winreg.SetValueEx(key, 'Path', 0, winreg.REG_SZ, path)
winreg.CloseKey(key)
try:
# Try to get the value of the Path variable
allPaths = winreg.QueryValueEx(key, 'Path')[0]
except Exception:
# Create the Path variable if it doesn't exist
add_var(path=AppPath)
return
# Get all the values of the existing paths
Path=allPaths.split(';')
# If the Path is empty, add the application path
if Path == ['']:
add_var(path=AppPath)
return
# Check if the application path is in the Path variable
if AppPath not in Path:
# Add the application path to the Path environment variable and add keep the others existing paths
add_var(path=AppPath+';'+allPaths)
# Only run this if the module is not imported by another
if __name__ == "__main__":
# Run the function
environment_var(AppPath=".")
You can find more information in the winreg documentation

- 256
- 2
- 6
You can also move your files to C:\Windows
, but you need to use Administrator privileges and pay attention.
What did I mean with pay attention?
You need pay attention because you can also do some messes with Windows system files (Windows may not even work anymore) if you modify, delete, and do some changes incorrectly and accidentally in this folder...
Example: Don't add a file that have the same name of a Windows file

- 111
- 2
- 9
This worked for me:
- put a .bat file with the commands you need (I use to run .py script into this) into a FOLDER,
- go in the variable environment setting (type var in the search bar and it will show up)
- in the global settings
- choose path,
- then modify,
- then add the path to your .bat file (without the .bat file)
- close everything: done.
Open the cmd, write the name of the .bat file and it will work
Example
Want to open chrome on a specific link
create a .bat file with this (save it as blog.bat for example)
start "" "https://pythonprogramming.altervista.org/"
go in enviromental variable settings from the search bar in the bottom left of the window desktop
go in enviromental variables (bottom button) then in path (bottom)
add the path, for example G:\myapp_launcher
click apply or ok
Now open cmd and write blog: chrome will open on that page
Do the same to open a file... create a .bat in the folder G:\myapp_launcher (or whatever you called the folder where you put the batch file), call it run.bat or myapp.bat or whatever (write inside of it start filemane.pdf or whatever file you want to open) and after you saved it, you can run that file from cmd with run or myapp or whatever you called your batch file.

- 22,305
- 3
- 41
- 34
I've spent a good hour trying to figure this out,
For whoever out there having the same problem,
If you need to run a .exe app from CMD or PS from anywhere in Windows, you need to add the Path of that .exe file into the "PATH" variable in Environment Variables to do so:
- From start menu > Type "Environment Variables" and press Enter
- System Properties > Advanced > Environment Variables
- Find "Path" and double click on it
- Click on New and enter the Path of the .exe file without adding the .exe file at the end
- Click Ok on all Windows and you should be good to go

- 41
- 4
Use a 1 line batch file in your install:
SETX PATH "C:\Windows"
run the bat file
Now place your .exe in c:\windows, and you're done.
you may type the 'exename' in command-line and it'll run it.

- 7,833
- 5
- 44
- 68
-
3Instead of placing custom executables into `C:\Windows`, one should rather add a custom directory to the `PATH` environment variable. – Roland Illig Oct 29 '16 at 01:48
Another way could be through adding .LNK
to your $PATHEX.
Then just create a shortcut to your executable (ie: yourshortcut.lnk) and put it into any of the directories listed within $PATH.
WARNING NOTE: Know that any .lnk files located in any directories listed in your $PATH are now "PATH'ed" as well. For this reason, I would favor the batch file method mentionned earlier to this method.

- 1
- 1
I'm not a programmer or anything of the sort, but here's my simple solution:
- Create a folder in which you'll be putting SHORTCUTS for all the programs you want to register;
- Add that folder to the
PATH
; - Put all the shortcuts you want in the folder you created in the first step (context menu, New, Shortcut...) The SHORTCUT NAME will have be the be summoned when calling the program or function... NOT THE TARGET FILE NAME.
This will keep you from unintentionally putting files you don't want in the PATH
.
Feel free to drop a comment if you think this answer needs to be improved. Cheers .
P.S. No system or File Explorer restart needed.

- 186
- 3
- 11
Best way is to add the folder path for the .EXE file to Path values in the environment variable.
I'm not sure what versions of Windows this works with, but I put some useful .bat
and .exe
files into:
%LOCALAPPDATA%\Microsoft\WindowsApps
(equivalent to %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
)
which seems to be on my default PATH. I'd be interested to see if this were the general case.

- 41,085
- 18
- 152
- 203
DOSKEY is a Microsoft version of 'alias'. That function is already built into all versions of Windows (and most versions of DOS)
doskey fred=c:\myApps\myprog.exe
You'll want to load that every time you open a command prompt. Which you can do by any number of different methods. One way is to
Make a file containing all the doskey macros you want:
doskey fred=c:\whatever.exe
doskey alan=c:\whateverelse.exe
Change the file type / file name / file extension to .CMD or .BAT
ren myfile.txt myfile.CMD
Add the CMD/BAT file to your command processor autoruns key:
reg ADD \\HKCU\Software\Microsoft\Command Processor /v autorun /t REG_SZ /d myfile.CMD
For more information see
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey
and https://serverfault.com/a/1049766/142882
(serverfault.com/questions/95404/is-there-a-global-persistent-cmd-history)

- 2,435
- 1
- 21
- 33
Should anyone be looking for this after me here's a really easy way to add your Path.
Send the path to a file like the image shows, copy and paste it from the file and add the specific path on the end with a preceding semicolon to the new path. It may be needed to be adapted prior to windows 7, but at least it is an easy starting point.

- 1
-
The essential part of an answer should be in a text, not in an external screenshot. – Roland Illig Oct 29 '16 at 01:50
The best way to do this is just install the .EXE file into the windows/system32 folder. that way you can run it from any location. This is the same place where .exe's like ping can be found

- 53
- 9
-
1Instead of placing custom executables into `C:\Windows`, one should rather add a custom directory to the `PATH` environment variable. – Roland Illig Oct 29 '16 at 01:49