Couldn't able to set the environment variables
-
Hi I'm trying to set envronment variables programatically using below code. But its failed to set the environment variables.
System.Environment.SetEnvironmentVariable("PATH", "C:\Dev");
Thanks in advance
Do you see any error messages?
//daniel
-
Hi I'm trying to set envronment variables programatically using below code. But its failed to set the environment variables.
System.Environment.SetEnvironmentVariable("PATH", "C:\Dev");
Thanks in advance
One thing I see wrong is your specification of the directory. Try:
System.Environment.SetEnvironmentVariable("PATH", @"C:\\Dev");
/ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Do you see any error messages?
//daniel
-
One thing I see wrong is your specification of the directory. Try:
System.Environment.SetEnvironmentVariable("PATH", @"C:\\Dev");
/ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Hi I'm trying to set envronment variables programatically using below code. But its failed to set the environment variables.
System.Environment.SetEnvironmentVariable("PATH", "C:\Dev");
Thanks in advance
Per the documentation: "Creates, modifies, or deletes an environment variable stored in the current process." (Emphasis mine) If you expect the settings to remain in place after the program completes, you'll be disappointed.
-
Hi I'm trying to set envronment variables programatically using below code. But its failed to set the environment variables.
System.Environment.SetEnvironmentVariable("PATH", "C:\Dev");
Thanks in advance
Following on PIEBALDconsult's reply, specify
EnvironmentVariableTarget.User
as the target if you want the environment variable to be set after your process ends. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
So, how do you know its failing? Do you attempt to read it once set or?
//daniel
-
So, how do you know its failing? Do you attempt to read it once set or?
//daniel