Why can't I use %USERPROFILE% in %PATH%?

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.


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.


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