PowerShell的 - 改变一个环境变量的值 [英] Powershell - changing the value of an environment variable

查看:125
本文介绍了PowerShell的 - 改变一个环境变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过PowerShell来更改环境变量(系统)的价值?我只能够手动更改值,请参阅重新启动的PowerShell后的变化。背景信息:我们试图动态地设置一个间接SSIS配置的值和所述配置文件是每环境不同。

Is there a way to change the value of an environment variable (system) through powershell? I have only been able to change the value manually and see the change after restarting powershell. Context: We are trying to dynamically set the value of an indirect SSIS configuration and the configuration file is different per environment.

推荐答案

要设置在系统级别的环境变量(并使其持久的),你需要使用.NET Framework方法 [环境] :: SetEnvironmentVariable方法()

To set an environment variable at the system level (and make them persistent), you need to use the .Net Framework method [Environment]::SetEnvironmentVariable()

在本届会议期间,您可以通过设置它们 $ ENV:NAME = VALUE

In the current session, you can set them via $env:NAME = VALUE.

请参阅<一href="http://technet.microsoft.com/en-us/library/ff730964.aspx">http://technet.microsoft.com/en-us/library/ff730964.aspx

这篇关于PowerShell的 - 改变一个环境变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆