G
Garfield
We have written a small function to append a couple of paths to the path
environmental variable. The code is:
string PathValue = "";
string sAdd = "";
sAdd = ";" + <path1> + "Bin;" + <path2>;
PathValue = System.Environment.GetEnvironmentVariable("Path");
PathValue += sAdd;
Microsoft.Win32.RegistryKey IniKey;
IniKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\
\Control\\Session Manager\\Environment", true);
IniKey.SetValue("Path", PathValue);
IniKey.Close();
This seems to work fine. However, the path environment variable is not
updated dynamically. It appears we have to reboot the computer for this
change to take effect. The problem is that we need the changes to take
effect immediately.
Using C#, is there any way to append a path or two to the path environment
variable so that it takes effect immediately?
Thanks in advance.
environmental variable. The code is:
string PathValue = "";
string sAdd = "";
sAdd = ";" + <path1> + "Bin;" + <path2>;
PathValue = System.Environment.GetEnvironmentVariable("Path");
PathValue += sAdd;
Microsoft.Win32.RegistryKey IniKey;
IniKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\
\Control\\Session Manager\\Environment", true);
IniKey.SetValue("Path", PathValue);
IniKey.Close();
This seems to work fine. However, the path environment variable is not
updated dynamically. It appears we have to reboot the computer for this
change to take effect. The problem is that we need the changes to take
effect immediately.
Using C#, is there any way to append a path or two to the path environment
variable so that it takes effect immediately?
Thanks in advance.