计算机\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment
RegistryKey localMachine = Registry.LocalMachine.OpenSubKey("SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment", true);
localMachine.SetValue("JAVA_HOME", "jdk目录位置");
string str = localMachine.GetValue("Path").ToString();
localMachine.SetValue("Path", "%JAVA_HOME%\\bin;" + str);
MessageBox.Show("配置成功!");
localMachine.Close();