1

First off, I'd like to apologise if this has already been covered. It's difficult to filter through all the existing issues similar to this one.

So in Windows there is two (as far as I'm aware) ways to set environment variables. First one is through the Command Prompt and the second is through System Properties in the Control Panel.

The former would be more desirable for me however I have an issue where the variable only lasts and exists in that session. This gets considerably annoying when I have to re-set my Java path every time.

The latter is what I have to resort to, it takes time and once in a blue moon I'll forget where to locate the menu.

Is there something I have to do in the Command Prompt to get it set permanently? Possibly a flag or switch to append to the command?

2
  • No. The life time of the cmd prompt ends when you close it. If you're too lazy remembering where the menu is, write a .bat file to set whatever you're setting and run it everytime you need. Also, the cmd to bring up that panel is sysdm.cpl. Commented Jul 2, 2015 at 6:57
  • I remember where to locate it, I just forget (though rarely). Did not know what the command was so thanks for that. Commented Jul 2, 2015 at 7:00

1 Answer 1

2

The SETX command can modify environment variables persistently:

Setx provides the only command-line or programmatic way to directly and permanently set system environment values.

It's quite a powerful tool but read the notes carefully on that page though because there are a few little catches to using it.

Sign up to request clarification or add additional context in comments.

1 Comment

Cheers for this. Just to make sure I'm getting it right, SETX JAVA_HOME "C:\Program Files\jdk1.8.x\bin" /m

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.