使用visual basic 2010设置环境变量 [英] Setting an environment variable with visual basic 2010

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

问题描述

我尝试在 Visual Basic 2010 中设置环境变量,如下所示:

Im trying to set an environment variable in Visual Basic 2010 as follows:

Module Module1
Sub Main()
        Environment.SetEnvironmentVariable("Variable", "Value")

 End Sub
End Module

但即使代码运行,

当我转到环境变量时>系统变量什么都没有

When i go to Environment Variables>System Variables Nothing is there

谁能告诉我怎么了?

推荐答案

默认情况下,环境变量仅为当前进程设置(并在从它产生的任何子进程中继承).您可能正在寻找 overload,它允许您指定 EnvironmentVariableTarget(您的情况下为机器或用户).

By default, the environment variable is only set for the current process (and inherited in any child processes that spawn from it). You're probably looking for the overload which lets you specify an EnvironmentVariableTarget (either Machine or User for your case).

这篇关于使用visual basic 2010设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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