I am using the Environment.SetEnvironmentVariable method call in C# (.NET 3.5) like this:
Environment.SetEnvironmentVariable( environmentVariable, value, "Machine" );
However this single call takes well over 2 seconds on several test systems (running both XP and Windows 7). I figured out that this might be because : "If target is User or Machine, other applications are notified of the set operation by a Windows WM_SETTINGCHANGE message." Is there any way to suppress this Notification to other applications so that my environment is set quickly and returns back..?
Note that I am having a component which sets around 20 environment variables and if I use the function as I have described above, it takes around a minute to finish that task.
Please suggest!!