Tuesday, December 9, 2014

windows 7 - Environment variables not loading on startup


I'm encountering a strange issue where it doesn't look like my environment variables are loading up properly whenever windows starts up. This was actually a pain to figure out what was happening and I did so purely by luck. I originally noticed the issue whenever I would restart or boot up and try to launch my standard set of applications. In particular, I would try to launch Eclipse and it would fail to start up and act as if I did not have a JDK.


While troubleshooting this, I would try to echo my environment variables (specifically, Path) and I would get the following:



C:\Windows\System32>echo %PATH%


C:\Windows\system32\NV;.;



At this point I would check on my environment variables and they would look fine. After a while, I noticed that after I performed this check, the variables would echo just fine:



C:\Windows\System32>echo %PATH%


C:\Program Files... [Many statements] ...;C:\apache-maven-3.0.4\bin



From what I gather, going into the environment variables forces them to reload or refresh. I'm not familiar with how environment variables are loaded on startup but it looks like this process isn't working. This is my work computer and there are a lot of background scripts that are run on startup so I suspect this might be the culprit.


If anyone has any ideas of what might be going on here I would appreciate the feedback, but I'm primarily wondering if anyone knows a way I can manually force a refresh of these variables on startup? A small script that I can run on startup or even in front of a few key applications to make sure the environment variables are loaded would be great. Thanks in advance for any input!


Answer



There's a command-line utility included in some Windows Resource Kits called setx that allows you make permanent changes to environment variables instead of temporary ones. It could be used in a batch file to set your PATH environment variable to what you want it to be.


No comments:

Post a Comment