-->

Friday, January 31, 2014

How to recover or modify your PATH variable on Windows

How to Recover or Modify your Path Environment Variable on Windows

When you need to run an executable from the command line, your operative system needs to know where to find it. Otherwise, you get an error like this one:

C:\> ping www.google.com
'ping' is not  recognized as an internal or external command, operable program or batch file.

To fix this, you need to add the directory in which that executable is located to your PATH environment variable.
Warning and disclaimer: don't touch this if you are clueless about what you are doing. The Path variable is used by your operative system even for the most basic of commands, if you delete it or make a mistake, your system could become unstable. I will NOT be held responsible for any damages or consequences whatsoever. 

How to Modify the Path Variable:

If you are not sure if the variable you are looking for is added to your Path or not and you don't want to use the GUI, you can try running cmd.exe and entering this command:
echo %PATH%
  1. Right click on 'Computer' and select 'Properties'
  2. Go to the Advanced Systems Settings section and select the 'Advanced' tab
  3. Click on 'Environment Variables'
  4. The Path variable is located on the second list, you might have to scroll down a little (see picture). Select it and click on 'Edit...'
  5. When modifying the Path variable, only add exactly what you need and don't remove anything else. When you are done, OK the changes. Make sure that you do not leave any spaces between the semicolons and add a semicolon to your final variable, e.g.:
C:\Windows\system32;C:\Python27;

The Path variable is selected in light blue.

I made a mistake before and nothing works. How do I recover my Path variable?

Follow steps 1-5, but add this variable:

%SystemRoot%\system32;%SystemRoot%;
Make sure that there are no trailing spaces anywhere (check the other variables), and that no variables are missing semicolons. This has been tested on Windows XP 32-bit and Windows 7 64-bit.
If this doesn't work, and you are using a very basic command (I like to test with 'ping'), you should check that the files themselves have not been deleted. Ping is usually located at C:\Windows\System32







No comments:

Post a Comment