Windows – How to make changes to environmental variables on Windows Server 2016 stick and stay permanent

classpathenvironment-variableswindowswindows-server-2016

After setting the CLASSPATH environmental variable on Windows Server 2016 using the Control Panel/System/Advanced Settings/Environmental Variables UI Tool – the CLASSPATH value reverts back to its original value when the system is restarted.

We looked at other answers and this was the method they described for setting the value permanently (i.e. as opposed to setting it at the command line which isn't.)

Why is this happening? How do we ensure the new value for the environmental variable stays to the value to which we set it?

Best Answer

The same way you do it in any other windows server version - by setting the environment variable on system level.

Alternatively from the command line look up a tool named setX which does that - but it will NOT change variables in other running processes, which are copied from the system settings at process start.

Related Topic