javawindowspowershellenvironment-variableswindows-10

How do I reset the dialog box interface for editing Environment Variables in Windows?


To experiment, I was trying to figure out a way to easily swap JDK versions in Windows 10. I previously had several values inserted into the PATH environment variable, like so:

edit environment variable dialog

Using the system interface to update the value of JAVA_HOME worked fine, but I wanted to see if I could use PowerShell to do this so I could make use of aliasing. So as a test, I ran (in non-admin mode)

setx JAVA_HOME "C:\Program Files\Java\jdk-11"
setx PATH "%PATH%;%JAVA_HOME%\bin"

If I remember correctly, setting the values this way worked but did not persist when I restarted the terminal and checked the environment variable. So, I added %SystemRoot%\system32 as a value at the very top, and then I moved the %JAVA_HOME%\bin value above it.

When I did this and ran the commands, it added a second JAVA_HOME variable into the user variables section (I deleted this), and it seemed to change the Path value to %PATH%;%JAVA_HOME%\bin. This works, but when I try to access the dialog box to edit, it changed into editing a user variable rather than an environment variable and now looks like this:

edit user variable dialog

The original PATH variable also seems to have changed. When I looked into the registry editor, several of those values that I had appear to be missing - it can't seem to find Maven (M2_HOME) or Dart Sass anymore via that environment variable, but it still recognized Python.

What happened? How can I reset this?


Solution

  • Okay, I see what's up, here's a solution: basically, the environment variable can't start with a percent sign unless it's the System Root one or it will break the interface, apparently it's a known bug.

    https://superuser.com/questions/1565006/path-environment-variable-is-represented-by-a-single-row-in-explorer-gui?rq=1