Question

I would like to append a directory on to the end of the PATH user variable using setx. Currently I have:

setx PATH %PATH%;C:\dir

Unfortunately this then inserts the entire contents of PATH, including the system variable part of "Path", into the user variable part. For example:

System Variable "Path"

C:\A
C:\B

User Variable "PATH"

C:\X
C:\Y

would turn into

System Variable "Path"

C:\A
C:\B

User Variable "PATH"

C:\A
C:\B
C:\X
C:\Y
C:\dir

when I run setx the command above.

Is there anyway I can avoid this duplication, and do a true "append" to PATH? What I want is:

System Variable "Path"

C:\A
C:\B

User Variable "PATH"

C:\X
C:\Y
C:\dir
Was it helpful?

Solution

Not possible using SETX, both are combined into the 1 PATH Variable

You will need to use registry such as

reg query HKCU\Environment /v PATH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top