user3389206
user3389206

Reputation: 495

Set environmental variable in VS12 C#

I want to apply the following fix: click me but I don't find how or where to set this. all I found is something with the command, but when I enter this in cmd it doesn't work..

Isn't there a simple file where I could edit this variable? Or a way to do it in the GUI?

Upvotes: 0

Views: 64

Answers (1)

Bernd Linde
Bernd Linde

Reputation: 2152

To programmatically change an Environment variable from within your application, you can use one of the following three commands:

Setting the environment variable for only the current process:

Environment.SetEnvironmentVariable("<VarName>", "<VarValue>", EnvironmentVariableTarget.Process);

Setting the environment variable for the current user:

Environment.SetEnvironmentVariable("<VarName>", "<VarValue>", EnvironmentVariableTarget.User);

Setting the environment variable for the entire system:

Environment.SetEnvironmentVariable("<VarName>", "<VarValue>", EnvironmentVariableTarget.Machine);

Additional information on Environment.SetEnvironmentVariable() with examples.

Upvotes: 1

Related Questions