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.

Possible Duplicate:
What are PATH and other environment variables, and how can I set or use them?

In Windows 2008 Server R2, once I set an environment variable in the command line, how can I make it stick? For example, it's easy to write:

set path=%path%;

much easier than the crummy right-click My Computer method. But once I set this, the changes disappear with my command window. How to make them stick? I want to do the same with JAVA_HOME and some others as well.

share|improve this question

marked as duplicate by slhck Aug 3 '12 at 15:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
setx may be best.. But cmd /? also mentions HKLM or HKCU\Software\Microsoft\Command Processor\AutoRun a bat file there could have the set PATH=.... line. –  barlop May 27 '11 at 8:05
    
@barlop: Setting "permanent" envvars through cmd's AutoRun is a hack. The page @slhck linked to has a better location - HKCU\Environment, which is loaded by Winlogon itself. (It's what setx uses, too.) –  grawity May 27 '11 at 14:11
add comment

1 Answer

up vote 7 down vote accepted

As mentioned in more detail in How do I set PATH and other environment variables?, you can use setx to set a variable permanently:

setx MyVariable "C:\Path\to\Folder"
setx JAVA_HOME "C:\Path\to\Java"

et cetera.

share|improve this answer
add comment

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