Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question
    
You could probably use setx in a batch file to set your PATH up the way you want it. –  martineau Dec 5 '12 at 19:34
    
This worked. If you drop it in an answer, I can accept it. –  ggrigery Dec 26 '12 at 15:33

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer

I seem to recal having this issue months ago ith a piece of software that pulls license info from the enviromental variables. We had been setting the USERS variables, but for some reason they were not staying consistantly. I ended up creating new SYSTEM variables,(that do not change based on the current user) and we haven't had any problems since.

Or you could creating a very simple batch file and place it in your StartUp folder.

//scratch that, variables set in a command window only persist within that command window instance

VBscript to the rescue!

Set wshShell = CreateObject( "WScript.Shell" )
Set wshSystemEnv = wshShell.Environment( "SYSTEM" )

' Display the current value
' comment out to remove dialog box
WScript.Echo "MyVariable=" & wshSystemEnv( "MyVariable" )

wshSystemEnv( "MyVariable" ) = "MyNewValue" 
' WScript.Echo "MyVariable=" & wshSystemEnv( "MyVariable" )

' Delete the environment variable
' uncomment to enable
'wshSystemEnv.Remove( "MyVariable" )

Set wshSystemEnv = Nothing
Set wshShell     = Nothing

save into a file with the ned extension as *.VBS

share|improve this answer
    
Thanks for the answer. I didn't try this because martineau's solution above worked for me. I may try to test this out later just to confirm whether or not it works. –  ggrigery Dec 26 '12 at 15:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.