环境变量值修改 [英] Environment Variable Value Modification

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

问题描述

亲爱的所有人
我需要将值设置为环境变量
我使用了下面的代码行

Dear All
I need to set value to an environment variable
I used the below line of code

Environment.SetEnvironmentVariable("TRACE", chkLogTrace.Checked.ToString(), EnvironmentVariableTarget.Machine);


它抛出System.Security.SecurityException

如何修改环境变量中的值?????

在此先感谢


Its throwing System.Security.SecurityException

How to modify the values in environment variable ?????

Thanks in advance

推荐答案

该代码似乎是正确的.要为EnvironmentVariableTarget.Machine设置环境变量,您需要以管理员身份登录或以管理员权限运行程序.
看到这里:
http://msdn.microsoft.com/de-de/library/96xafkes.aspx [ ^ ]
然后在这里:
http://msdn.microsoft.com/de-de/library/system. security.permissions.environmentpermission.aspx [ ^ ]
The code seems to be correct. To set the environment variable for EnvironmentVariableTarget.Machine you need to be logged in as administrator or run your program with admin rights.
See here:
http://msdn.microsoft.com/de-de/library/96xafkes.aspx[^]
and here:
http://msdn.microsoft.com/de-de/library/system.security.permissions.environmentpermission.aspx[^]


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

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