Setting Environment Variable using C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Setting Environment Variable using C#

 
0
  #1
May 30th, 2008
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!
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Setting Environment Variable using C#

 
0
  #2
May 31st, 2008
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.
KSG
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 127
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: Setting Environment Variable using C#

 
0
  #3
Jun 5th, 2008
Thank you very much... I assume the Value is the path.... Thank you...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC