DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Setting Environment Variable using C# (http://www.daniweb.com/forums/thread126971.html)

johnroach1985 May 30th, 2008 5:49 pm
Setting Environment Variable using C#
 
Hi ! I am working on this project; the thing is that I want my program to create it's own environment variable path so it can be called from and used in CMD too. How can I do this... Googling hasn't been any help yet. Thanks in advance!

selvaganapathy May 31st, 2008 9:48 am
Re: Setting Environment Variable using C#
 
Hi
U can use
public static void SetEnvironmentVariable (
        string variable, string value,
        EnvironmentVariableTarget target
)

or

public static void SetEnvironmentVariable (
        string variable, string value,
)

EnvironmentVariableTarget target Takes Three values
 > Machine
 > User
 > Process
Example

Environment.SetEnvironmentVariable("MYVARIABLE", "MyValue", EnvironmentVariableTarget.Machine  );

Note: This method is new in the .NET Framework version 2.0.

johnroach1985 Jun 5th, 2008 10:54 am
Re: Setting Environment Variable using C#
 
Thank you very much... I assume the Value is the path.... Thank you...


All times are GMT -4. The time now is 7:17 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC