Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my Windows 7 machine, using the System Properties > Environment Variables tool, I try to add %USERPROFILE%\Bin to the system variable PATH. For some reason, that doesn't work, even though %SystemRoot%\system32 works fine.

When I try to run commands from the console, files in my Bin folder are not found, even though files in the System32 folder are found.

The only difference between UserProfile and SystemRoot that I can see is that the former is a user variable while the latter is a system variable.

I i write echo %USERPROFILE%\Bin it yields c:\Users\zano, and if I add c:\Users\zano\Bin explicitly, everything work fine.

What's the problem here?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

System variables are set before user variables are. Consequently, at the time system variables are being set, none of your user variables exist yet.

You may be able to create a new user variable called PATH and set it to "%USERPROFILE%\Bin;%PATH%". I have not tested it, but it may do what you want. USERPROFILE might still not be set, though, so you might need to hard-code the path into your user variable, but at least it won't affect other users on the computer.

share|improve this answer

Stephen Jennings was right, but just a little clarity. In Windows, if the User variable Path exists, it is automatically appended to the System variable Path. The User variable Path is permitted to use %UserProfile% while the System variable gets the literal text "%UserProfile%".

So creating User variable "Path" and setting it to %UserProfile%\Bin was all that was needed.

Example 1:

System Variable Path = C:\WINDOWS\ User Variable Path = %UserProfile%\Bin

User's path will be

C:\WINDOWS;C:\Users\User\Bin

Example 2:

System Variable Path = C:\WINDOWS\;%UserProfile%\Bin

User Variable Path is not set at all.

User's path will be

C:\WINDOWS\;%UserProfile%\Bin

You don't want Example 2.

share|improve this answer

Similar to what Stephen said but

Create a user environment variable called PATH Within this you can use %USERPROFILE% correctly - USERPROFILE is expanded before user section is processed. This user PATH will be automatically appended to the system path so no need to add the %PATH% part.

e.g.

System variable: PATH=c:\path1 User variable PATH=%USERPROFILE%\path2

Resulting path: PATH=c:\path1;C:\Users\myuser\path2

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.