When working in the Windows command line interface (cmd.exe), there are many times when you want to run an executable that’s located in another folder. Most often, this folder is C:\Program Files or a sub-directory thereof. For your convenience, many Windows installers will automatically update your system PATH environment variable so you can type the name of the executable from any directory and run that .exe file. For example, notepad.exe is located in C:\Windows\System32. But you can type “notepad” in the command line from any directory and it’ll launch notepad.exe.
Not all program installers will modify your PATH environment variable to enable this. Fortunately, you can set or modify the PATH system variable in Windows very easily. Here’s how:
Click Start –> Computer –> System Properties.
Click Advanced system settings.
From the Advanced tab, click Environment Variables…
In the bottom pane, scroll down to the variable named Path. Select it and click Edit.
In the variable value field, add a semicolon and then the path where the .exe you want to run from the command line is located. Be careful not to delete anything that’s already in the field, otherwise you might break another program.
For example, I’m adding C:\Program Files\SendEmail by pasting in only the selected text in the screenshot.
When you are done, click OK. If you have cmd.exe open, close it and re-open it. Test out your modified PATH variable by typing in an .exe from the path you just added.
Before you made this tweak, you would’ve gotten the error: ‘xxxx’ is not recognized as an internal or external command, operable program or batch file.
After the tweak, the executable will run no matter what directory you are in.
And that’s all. Not a hugely life-changing tip on its own, but combined with some other groovy tips I’ve got in store, it’ll make a world of difference. Stay tuned
Here is the step by step tutorial I follow to set PATH for Java in Windows 7 and Windows 8