How to set environment variable Path using C#
You are associating the environment variable with your program, but instead you want to associate it with your local machine in order to make it available to every program. Look at the overload that takes an EnvironmentVariableTarget
.
var name = "PATH";
var scope = EnvironmentVariableTarget.Machine; // or User
var oldValue = Environment.GetEnvironmentVariable(name, scope);
var newValue = oldValue + @";C:\Program Files\MySQL\MySQL Server 5.1\bin\\";
Environment.SetEnvironmentVariable(name, newValue, scope);