Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set environmental variables permanently through a batch file. Is there a command to set Permanent Environmental Variable (other than SETX) for Windows XP service pack 3?

command SETX JAVA_HOME="C:\java\jdk-1.4" is not supported in my machine. It is Windows XP service pack 3.

share|improve this question
you mean specifically via command-line? or will a control panel suffice? – quack quixote Apr 27 '10 at 4:59
I want to do it through the batch file since it should be done for several machines. – shyameniw Apr 27 '10 at 5:27
You can also use SETX. See this superuser post. – Mark Mikofski Nov 15 '12 at 8:17
He said specifically that setx is not an option – Jaime Hablutzel Feb 13 '13 at 17:34
up vote 8 down vote accepted

Per user settings command line:

% reg add KEY  /v JAVA_HOME /t REG_SZ /d "C:\java\jdk-1.4"

For user only settings replace KEY with:


For per machine settings replace KEY with:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

(Attention: there is a space in the last key, quote it with " !)

share|improve this answer
thanks I'll try that! – shyameniw Apr 27 '10 at 5:28
ah its working fine. thanks! – shyameniw Apr 27 '10 at 5:34
hey can u tell me where can i find similar commands like this one. – shyameniw Apr 27 '10 at 5:38
define "similar". modifying the registry? thats not so similar to, lets say, deleting files. best way to find things is to have a problem and to search for an answer here on superuser and, if nothing fits, ask your next question – akira Apr 27 '10 at 6:03
hey hey thank. Got what i wanted. Good work. Saved the day.Thanks again. – shyameniw Apr 27 '10 at 8:40

Your Answer


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.