How to invoke a program in Windows from command prompt?
I've added Notepad2 path to Path
And when I do notepad2 somefile.js - it says it's not recognized as an internal or external command.
I tried notepad2.exe - still doesn't work. What else I should do to be able to do what I can do with notepad? i.e. notepad somefile.txt - boom, opens it.
Solution 1:
You need to add the path of the folder containing notepad2.exe
not the full path to the actual exe
. So use:
C:\Program Files\Notepad2\
NOTE: Changes you make to your PATH (or any other Environment Variable) do not take effect in programs that are already running. The easiest way to make sure that your changes take effect for all programs is to log out and then back in again (or restart the computer, if you also want Windows System Services to see the change). However, if you just need to use the changes in the Command Prompt, it is enough to close the cmd
window and reopen it.
Solution 2:
Depending on what you are doing, it is also possible to use the "App Paths" registry key.
This is how you are able to launch a number of applications, e.g. Chrome, Firefox, notepad++.exe, etc.., without them being in your "PATH".
Plus, it's best to keep the PATH variables as clean as possible, it will save a number of unnecessary files searches when the Search path is used. The order of the values in the path should also be considered for this reason.