Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SETX doesn't append path to system path variable

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?

like image 655
Hamed Kamrava Avatar asked Jun 21 '13 17:06

Hamed Kamrava


People also ask

How do I add a directory to the PATH System environment variable?

To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.

How do I set Environment Variables in Setx?

To set a System Environment Variable rather than a User Environment Variable, we just need to use the /m option in the setx command and run it from an elevated(Administrator) Command Prompt.

How do I enable System Variables in Environment Variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

What is the use of Setx () function?

The Setx command also retrieves the values of registry keys and writes them to text files. This command provides the only command-line or programmatic way to directly and permanently set system environment values. System environment variables are manually configurable through Control Panel or through a registry editor.


1 Answers

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.

like image 110
mojo Avatar answered Sep 19 '22 00:09

mojo