Friday, October 30, 2015

windows server 2008 - Set environment variables from command line - and make them stick globally






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.


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...