Adding a directory to the PATH environment variable in Windows
I am trying to add C:\xampp\php
to my system PATH
environment variable in Windows.
I have already added it using the Environment Variables dialog box.
But when I type into my console.
C:\>path
it doesn't show the new C:\xampp\php
directory.
PATH=D:\Program Files\Autodesk\Maya2008\bin;C:\Ruby192\bin;C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\System32\Wbem;C:\PROGRA~1\DISKEE~2\DISKEE~1\;c:\Program Files\Microsoft SQL
Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;D:\Program Files\TortoiseSVN\bin
;D:\Program Files\Bazaar;C:\Program Files\Android\android-sdk\tools;D:\Program Files\
Microsoft Visual Studio\Common\Tools\WinNT;D:\Program Files\Microsoft Visual Studio\Common
\MSDev98\Bin;D:\Program Files\Microsoft Visual Studio\Common\Tools;D:\Program Files\
Microsoft Visual Studio\VC98\bin
Two questions
- Why did this happen? Is there something I did wrong?
- Also, how do I add directories to my
PATH
variable using the console (and programmatically, with a batch file)?
Best Answer
Option 1
After you change PATH
with the GUI, close and re-open the console window.
This works because only programs started after the change will see the new PATH
.
Option 2
In the command window which is open execute this command
set PATH=%PATH%;C:\your\path\here\
This command appends C:\your\path\here\
to the current PATH
.
Breaking it down.
set
– A command that changes cmd's environment variables only for the current cmd session ; other programs and the system are unaffected.PATH=
– Signifies thatPATH
is the environment variable to be temporarily changed.%PATH%;C:\your\path\here\
– The%PATH%
part expands to the current value ofPATH
, and;C:\your\path\here\
is then concatenated to it. This becomes the newPATH
.