As an addendum to @ajp15243's answer. If you are doing the same with PowerShell rather than the command prompt or batch file, you'll need to call SETX
with a leading escaped double-quote character, as in:
$my_path = "%PROGRAMFILES%\MySQL\MySQL Server 5.7\bin\"
$hkcu_path = (Get-ItemProperty hkcu:\Environment).PATH + ";" + $my_path
SETX PATH "`"$hkcu_path" # note the leading escaped quote
However doing so, may result in adding a trailing double quote in the value of hkcu:\Environment\PATH
, so you may need to do this too:
$dirty_path = (get-itemproperty hkcu:\Environment).PATH
$clean_path = $dirty_path -replace '"',''
SETX PATH $clean_path