This is a simple change that can make using the Windows command line much easier. Adding a directory to the Windows PATH will mean Windows will search the directory when a command is entered. The main reason for doing this is that it acts as a shortcut for common applications you may run.
For example, instead of typing the pull path to launch an application (as in example 1), you can type a much shorter version:
"C:\Program Files\SomeProgram\Bin\MyProg.exe" --some-arg
This has three main advantages:
- Looks Neater – This can be important if you're using batch files. Long lines are hard to read, so shortening things is a good idea.
- Less Typing – Speaks for itself. If you use the command line or batch files for any amount of time, you'll appreciate how much easier it is to use if you're not typing full paths for your tools.
- Portable – Perhaps the most important detail. Not using hard-coded paths makes it easier to port your batch files to other machines.
Note: Be careful when editing your path variable, as you could render some programs unusable if you make a mistake. Also remember that changes won't take effect until you restart the console.
1 – Right click "My Computer" and select "Properties" OR goto Control Panel and select "System". This will open the "System Properties" window.
2 – Switch to the “Advanced” tab, and select "Environment Variables".
3 – There are now two options. You can modify the global path variable, or add your own to your personal profile. If you want all users on the machine to have the same shortcut, add it to the global path, otherwise use the local one.
a. To modify the global path variable – Find "Path" or "PATH" in the lower window (marked Global variables). Select Edit. Add the path to your application. Separate paths with a semi-colon (;). Add trailing slashes if you wish.
b. Either modify an existing one using the tutorial above, or select "new", then enter "PATH" as the name of the variable and enter the path value in the environment value section.
If you'd like to do this using the command line, you can use the "setx" command
included with Windows XP service pack two. To add the directory "
files\SomeProgram\Bin" to your path, use the following:
setx path "%PATH%;C:\Program Files\SomeProgram\Bin"
Remember to include the
%PATH% variable at the start of your
setx command so
that you'll keep existing path names.