Set env variables in current process: set JAVA_HOME='D:\jdk8';
Set env vars globally: setx JAVA_HOME 'D:\jdk8';
Print a env var: echo %JAVA_HOME%.
Ref: https://superuser.com/questions/79612/setting-and-getting-windows-environment-variables-from-the-command-prompt