Set machine-level environment variables from the command line in Windows 7 and above:
setx <variable> <value> /m
Example: setx JAVA_HOME “C:\Program Files\Java\jre1.8.0_45” /m
Hint: “/m” must be last, and is what adds it at the machine level.
Append path to the PATH variable:
setx PATH “%PATH%;C:\Program Files\Java\jre1.8.0_45” /m
Note that the new environment variables take affect for the NEXT command session, not the current one.