Part of your problem is that SETX
isn’t SET
–– after you do
setx JAVA_HOME "C:\Program Files (x86)\Java\jdk1.7.0_21" /m
…, %JAVA_HOME%
isn’t set in that instance of the Command Prompt.
You’d have to start a new instance to get %JAVA_HOME%
, et. al., set.
I suggest you do something like
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_21
setx JAVA_HOME "%JAVA_HOME%" /m
I don’t see why you would be deleting part of the original path. Access/modify the User path variable, not System path may be relevant. And you might want to do
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v path
to get the system part of the PATH variable, excluding the user part.