If I execute set PATH=%PATH%;C:\\Something\\bin
from the command line (cmd.exe
) and then execute echo %PATH%
I see this string added to the PATH. If I close and open the command line, that new string is not in PATH.
How can I update PATH permanently from the command line for all processes in the future, not just for the current process?
I don't want to do this by going to System Properties → Advanced → Environment variables and update PATH there.
This command must be executed from a Java application (please see my other question).
You can use:
setx PATH "%PATH%;C:\\Something\\bin"
However, setx
will truncate the stored string to 1024 bytes, potentially corrupting the PATH.
/M
will change the PATH
in HKEY_LOCAL_MACHINE
instead of HKEY_CURRENT_USER
. In other words, a system variable, instead of the user's. For example:
SETX /M PATH "%PATH%;C:\your path with spaces"
You have to keep in mind, the new PATH is not visible in your current cmd.exe
.
But if you look in the registry or on a new cmd.exe
with "set p"
you can see the new value.