Warm tip: This article is reproduced from stackoverflow.com, please click
batch-file cmd setx system-variable windows

SETX doesn't append path to system path variable

发布于 2021-01-11 21:33:21

I have tried below command to append some path to system path variable by batch-file :

setx PATH "%PATH%;C:\Program Files\MySQL\MySQL Server 5.5\bin"

I have checked system variable path after running above batch-file, above path isn't in there.

enter image description here

You can see all windows Variable value content in below :

C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMDAPP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles (x86)\ATI Technologies\ATI.ACE\Core-Static;

What am i doing wrong?

Questioner
Hamed Kamrava
Viewed
0
mojo 2013-06-22 12:18

To piggy-back on @Endoro's answer (I lack the rep to comment):

If you want to change the system-wide environment variables, you have to use /M, a la:

setx PATH "%PATH%;C:\Program Files\MySQL\MySQL Server 5.5\bin" /M

setx.exe is picky about placement of the /M, BTW. It needs to be at the end.