Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to add a PATH from command line, as with SETX %PATH%... it always expands the PATH, which I don't want.

PATHMAN is exactly for this purpose, but it doesn't work for me on Windows 7. It freezes most of the times, and it doesn't check for duplicated.

There must be a tool for managing PATH variables in the proper way. SETX would be perfect, but maybe not with the %PATH% syntax.

share|improve this question

2 Answers

up vote 6 down vote accepted

See the article Edit the PATH environment variable in Windows without pain.

It recommends using pathed :

For example, say that you have your Sysinternal tools in C:\Bin\Sysinternals and you want to add them to the PATH. Simply do:

pathed /append C:\Bin\Sysinternals /machine

If you want to add them to the user PATH system instead, then do:

pathed /append C:\Bin\Sysinternals /user
share|improve this answer
This is exactly what I was looking for! From the article, I have tried the other 3 solutions already without happiness. It seems this is the one I was looking for. Works perfectly! BTW, it has nothing to do with Sysinternals. – zsero Apr 8 '11 at 16:27
This is supposed to work but it has an essential bug, if you try to ADD/APPEND something to the the user path and user path is not defined the utility will fail to add the path. – Sorin Sbarnea Sep 21 '11 at 14:22
I just gave this app a try; it was frustrating that it didn't seem to work. I realized that I have to run it while logged in as an Administrator, OR run it in a command shell that was started with "Run as Administrator". Also, you may need to categorically use "/machine" if you want affect the machine level path. Good luck! And thanks to @harrymc for the tip; +1 from me! – Dan H Sep 12 '12 at 13:17

(I know that you've already answered this question, but)

The problem with your usage of setx is that you are not quoting the string that you want to be set. Because the ; character is a command delimiter (you can string commands to be run in-succession with it), it thinks that you are setting path and then running another command.

What you should do is this:

setx /M path "C:\perl\bin;%path%"

This prepends my %path% variable with C:\perl\bin, because I want it to come before anything else that may be installed. The /M means that I mean the System EnvVar, not the user's.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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