When you run something from the start menu or in a Windows command prompt, you type the program name to run the executable file. There are three ways in which you can execute something:
- the executable is in your current directory/folder
- you type the entire path to the executable.
- the PATH environment variable contains a value that points to the folder containing the executable.
The first and second items are fairly self explanatory. In a command prompt, if I change to the \Windows folder in Windows 7, I see these executables:
If I type notepad (the .exe isn’t required), Windows searches the folder, finds notepad.exe, and runs it.
If I am in c:\Users\Steve, however, I can run notepad in one of two ways. I can do this:
The other way is that I just type notepad, and it runs. How does this happen? It’s a holdover from DOS (and Unix) for an environment variable called PATH. My current path is returned by typing PATH in a command prompt.
There are a lot of folders listed here, all separated by a semi colon. Most of these are for various programs, and lots of installers alter the path to add their own folder. For example, the Live suite of products added this path
C:\Program Files (x86)\Windows Live\Shared
I would have thought most technical people knew how to change the path, but I found a developer recently that did not. I suspect most people don’t need to deal with this in most cases, so they aren’t aware.
The way you should change this manually in Windows is this. Go to the properties of your system by right clicking the “Computer” item in the Start Menu and select Properties. You’ll get this screen (in Windows 7)
Select the “Advanced System Settings” in the left side. This is an admin function, so you need the UAC permission. This will open a new dialog
The Environment variables are accessed through a button on the Advanced tab. Once you press that, it will give you the variables dialog.
If you scroll down in the System Variables, you’ll see PATH as an item. Select “Edit” and you can change the path.
The path is selected when this opens.
DO NOT START TYPING.
Instead hit the right arrow to de-select all the txt and move to the end (as shown in the image above). Add a semi-colon and your path, and OK back out of all dialogs. You’ll have a new path that you can use in your system.
Filed under: Blog Tagged: syndicated, windows