简体   繁体   中英

Set environment variable - SETX

I need to set a system environment variable for Java. I'm currently using this method:

setx /M JAVA_HOME "C:\Program Files (x86)\Java\jdk1.6.0_17"

My question: Is there a better (PowerShell) way to do this?

I tried using:

[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files (x86)\Java\jdk1.6.0_17")

But this does not produce the same result as setx .

Is there a better PowerShell way to set Java home?

您是否尝试设置范围?

[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files (x86)\Java\jdk1.6.0_17", "Machine")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM