TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
travis.hurst
NA
13
0
Setting Environment Variables in .NET
Oct 21 2004 5:05 AM
I need a way of setting environment variables on the fly in C#. I have found a way using the registry but I have to reboot my machine before it becomes available to read. See below =============== public static bool setEnvVar(string name, string Value) { try { //check the parameters if(name!=null && Value!=null) { RegistryKey key1=Registry.LocalMachine .CreateSubKey(@"SYSTEM\ControlSet001\Control\Session Manager\Environment"); ; key1.SetValue(name,Value); return true; } else { MessageBox.Show("The parameters for the setEnvVar function were invalid"); return false; } } catch(Exception ex) { MessageBox.Show("Exception in setEnvVar "); MessageBox.Show(ex.Message); return false; } } ============== Is there a way to do it so it become available straight away (like using the cmd window) ? There only seems to be Reading Env Variables defined in .NET Can someone help?
Reply
Answers (
0
)
DataGrid , HeadClick Event
Easy XML question (when you know it!)