Does the following add an environment path?

setx path "%path%;C:\foo"

It will leave any existing paths alone? i.e nothing will be deleted?

If I open the Visual Studio Command Prompt and run the above will it add an environment path to that applications properties or will it change the general command line's properties?


The proper syntax would be:

setx path %path%;C:\foo

This will append C:\foo to the PATH environment variable.

See this page for examples of the syntax.

Ok, so the more that I research this, and having tried it now in my local copy of Visual Studio 2010, it appears that setx doesn't work there. Following this link is the only Microsoft version that I can find http://technet.microsoft.com/en-us/library/cc755104(v=ws.10).aspx but it changes Server environment variables.

set path %path%;C:\foo appears to be your only option

To answer your question in the comments, doing a set in the command line does not permanently change things, it only changes them for the duration of your session.

If you want to change the environment variables for a Visual Studio project it looks like you have to do that in the project properties. http://msdn.microsoft.com/en-us/library/ms173406.aspx http://msdn.microsoft.com/en-us/library/ee479070(v=winembedded.60).aspx

  • I assume the environment variables for Command Line and VS Command Prompt are different? If I have VS Command Prompt open and run this code it will specifically amend the VS Command Prompt's variables i.e not the normal command line's variables? – whytheq Oct 5 '12 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.