I understand your frustration. It seems that you are facing a common problem with Windows environment variables that are not parsed correctly in some situations. There are a few possible reasons and solutions for this issue:
- One reason is that the environment variables are read from the registry in alphabetic order, and if you have a variable that depends on another variable that is alphabetically greater, the first variable will not be expanded. For example, if you have CLASSPATH depending on JAVA_HOME, and both are REG_EXPAND_SZ type, CLASSPATH will not be expanded because C < J. A solution for this is to change the order of the variables or use REG_SZ type for JAVA_HOME<sup>1</sup>.
- Another reason is that the environment variables are not refreshed in the current command prompt, but only in subsequent ones. This means that if you change a variable using setx.exe, you will not see the effect in the same command prompt, but only in a new one. A solution for this is to use refreshenv command to refresh the environment variables without restarting the command prompt<sup>2</sup>.
- A third reason is that there are white spaces in the environment variables that cause parsing errors. For example, if you have a space at the end of JAVA_HOME, it will not be recognized correctly. A solution for this is to remove any white spaces in the environment variables<sup>3</sup>.