I have a VB .Net Application that wants to set an environment variable in the System settings. According to the MSDN, the System.Environment.SetEnvironmentVariable can do this, for example:
Problem is, when I execute this code I get a SecurityException. I assume I need to have administrator rights (I am running on Windows 7).Code:System.Environment.SetEnvironmentVariable(_ENV_NAME, value, EnvironmentVariableTarget.Machine)
I have done some searching in the forums but cannot find a good example of manipulating system settings that require elevated privileges. I have similar issues with modifying a registry key. The variables and keys need to be present for all users of the machine, so that is why I want to modify these settings. I don't even know where to start. The MSDN is very confusing on this topic.




Reply With Quote