Windows – CMD doesn’t update environment variables even when restarting the OS

command lineenvironment-variableswindows

I've been setup my variables for my development environment using the Windows cmd, but it works well only the first time I set them with the System>Advanced>Env Vars dialog. I just restart cmd and it works.

But after I restart the computer, it behaves quite weird. Like I have to restart cmd an indeterminate number of times for it to get the variables I set. Sometimes it even shows in the cmd when I issue the command SET, but it doesn't work if I issue a command from one of those paths. This is how it looks:

C:\Users\Adrian>set
ALLUSERSPROFILE=C:\ProgramData
ANDROID_HOME=F:\Programas\android-sdk
ANDROID_SDK_HOME=F:\Programas\android-sdk
ANT_HOME=F:\Programas\ant
APPDATA=C:\Users\Adrian\AppData\Roaming
BIN_DIR=F:\Programas\bin
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=SAKURA
ComSpec=C:\WINDOWS\system32\cmd.exe
configsetroot=C:\WINDOWS\ConfigSetRoot
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Adrian
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_60
JAVA_SDK_HOME=C:\Program Files\Java\jdk1.7.0_60
LOCALAPPDATA=C:\Users\Adrian\AppData\Local
LOGONSERVER=\\SAKURA
MAVEN_HOME=F:\Programas\maven\
MOZ_PLUGIN_PATH=C:\PROGRAM FILES (X86)\FOXIT SOFTWARE\FOXIT READER\plugins\
NUMBER_OF_PROCESSORS=8
OS=Windows_NT
Path=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x8
6)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:
\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:
\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\
Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Int
el(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Man
agement Engine Components\IPT;C:\Program Files\Lenovo\Bluetooth Software\;C:\Pro
gram Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files\nodejs\;%ANDROID_
HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin;F:\Programas\ant\bin;C
:\Program Files (x86)\Git\cmd;C:\Program Files\Microsoft SQL Server\110\Tools\Bi
nn\;C:\Program Files (x86)\sbt\bin;F:\Programas\bin;%MAVEN_HOME%\bin;C:\Users\Ad
rian\AppData\Roaming\npm
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3c03
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SBT_HOME=C:\Program Files (x86)\sbt\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\Adrian\AppData\Local\Temp
TMP=C:\Users\Adrian\AppData\Local\Temp
USERDOMAIN=SAKURA
USERDOMAIN_ROAMINGPROFILE=SAKURA
USERNAME=Adrian
USERPROFILE=C:\Users\Adrian
VBOX_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools
\
windir=C:\WINDOWS

C:\Users\Adrian>adb
"adb" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\Users\Adrian>adb
"adb" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\Users\Adrian>javac
"javac" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

C:\Users\Adrian>

There is a var called ANDROID_SDK_HOME that was replaced by ANDROID_HOME. That first one doesn't even exist in the registry!

Registry for user vars:
user vars

Registry for system vars:
system vars

What could be wrong?

PD: This is on Windows 8.1 Update 1

Best Answer

The following link may be of use What are path and other environment variables and how can I set them

I note that you have javac as one of the commands you are testing which would be part of the Java SDK and while you appear to have set the following environment variable

JAVA_SDK_HOME=C:\Program Files\Java\jdk1.7.0_60

there is no %JAVA_SDK_HOME% in your path statement so the OS would possibly not find that command in your other path entries.

Related Question