2 Replies - 281 Views - Last Post: 23 August 2018 - 04:40 AM Rate Topic: -----

#1 Faz221   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-August 18

Need to be able to change and add System environment variables in CMD

Posted 23 August 2018 - 03:23 AM

I would like to be able to add new and edit current System Environment Variables from the Command Prompt. I know that this can be done manually by going into Control Panel > System > Advanced > Environment Variables. But I would like to be able to do it using the command line and be able to, ultimately, put it into a Batch File.
I have tried:
setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_04"

I have also tried:
setx <EnvironmentVariableName>=<EnvironmrntVariableValue>


Is there any other way that I can do the task. I do not want to affect the path variable all of the time but I want to be able to add new ones and to be able to edit current ones.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Need to be able to change and add System environment variables in CMD

#2 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2279
  • View blog
  • Posts: 4,362
  • Joined: 30-May 10

Re: Need to be able to change and add System environment variables in CMD

Posted 23 August 2018 - 04:32 AM

https://docs.microso...s-commands/setx

Quote

The set command, which is internal to the command interpreter (Cmd.exe), sets user environment variables for the current console window only.

Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • dependency injected
  • member icon

Reputation: 6668
  • View blog
  • Posts: 27,305
  • Joined: 12-December 12

Re: Need to be able to change and add System environment variables in CMD

Posted 23 August 2018 - 04:40 AM

That first statement works for me on Windows 10.

How do you know it is not working? Is there an error message?

Otherwise, maybe there is a permission issue; can you create an environment variable via the Control Panel?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1