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.
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?
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.
Does SETX fail to set more than 1024 characters? When i executed SETX PATH "%PATH%;C:\Temp" it did the job (for 1024 chars) but also warned: The data being saved is truncated to 1024 characters. Any way to get around it? And i DON'T want to do make it happen by editing registry.
Editing the registry isn't bad. The only thing it doesn't do is send the WM_SETTINGSCHANGE message. You could always set the registry value then use setx to set/unset some meaningless value.
@kalehv: pretty sure the limitation isn't
setx
per-se in that case. The command line size limits are much more severe on Windows than on Linux, for example.I also had to start a new command prompt window before the new path usable.
SETX changes the global environment variable but processes must check to see if it's been updated. CMD.EXE doesn't ever check. To change a variable within CMD, use SET (e.g.
SET "PATH=%PATH%;C:\path\to\bin\dir"
)