How to change PATH in windows OS via cmd

875 views Asked by At

I am trying to add a path, in PATH variable. I run cmd.exe as administrator and used

setx PATH "%PATH%;C:\MinGW\bin"
setx PATH "%PATH%;C:\MinGW\msys\1.0\bin"

I then restarted my computer, but if I type path I don't see the paths that I set there. Note that with the exact same way I was able to set some other directories on PATH.

Any idea on what might be wrong?

2

There are 2 answers

1
tdolydong On BEST ANSWER

you should use

"My Computer" > "Properties" > "Advanced" > "Environment Variables" > "Path".
3
Magoo On
setx PATH "%PATH%;C:\MinGW\bin"
setx PATH "%PATH%;C:\MinGW\msys\1.0\bin"

Should first set PATH to "%PATH%;C:\MinGW\bin" and then to "%PATH%;C:\MinGW\msys\1.0\bin", so the second setx overrides the first because setx does not set the variable in the current or existing CMD sessions - only new ones.

setx PATH "%PATH%;C:\MinGW\bin;C:\MinGW\msys\1.0\bin"

theoretically should set PATH with those two directories appended - for future sessions.

You can check by simply starting a new session and executing a

path

command.

If the change doesn't survive a reboot, then some other process is resetting it.

If the change doesn't occur at all, then there's something mighty fishy going on. Possibly a typo...

I'd try setting some other variable as a test, say mypath.

You can delete a variable using

setx mypath ""

Googling for PATH EDITOR may be useful...