Windows 7自定义环境variables消失

我想在Windows 7中设置一个自定义环境variables,这需要以编程方式完成,因为它必须在多台计算机上进行设置。

我一直在testing一个单一的机器,但是当我以编程方式创build它时,它存在于该会话中(即,在命令窗口处于打开状态的DOS下,或在ISE打开时在Powershell中) – 然而,当closures会话时variables消失了?

我如何使它永久?

谢谢,

为用户
wmic环境创build名称='testing',variablevalue ='空气',用户名='域\用户名'

为电脑
wmic环境创build名称='testing',variablevalue ='空气',用户名='系统'

可以使用/ node:paramter远程工作

也许矫枉过正

http://blogs.technet.com/b/heyscriptingguy/archive/2010/06/03/hey-scripting-guy-can-i-use-windows-powershell-to-read-a-text-file-and-更新的环境variables-上远程computers.aspx

基本的语法是:

[Environment]::SetEnvironmentVariable(<name>,<value>,<EnvironmentVariableTarget>) 

这将为login用户创build一个新的永久envvariables:

 [Environment]::SetEnvironmentVariable("NewVar","NewValue","User") 

而这一个为系统:

 [Environment]::SetEnvironmentVariable("NewVar","NewValue","Machine")