protected void SetRegistryValue(RegistryKey root, string subkey, string key, string value)
{
try
{
string reg;
value = value.Replace("\\", "\\\\");
reg = "Windows Registry Editor Version 5.00" + Environment.NewLine + Environment.NewLine + "[" + root.ToString() + "\\" + subkey + "]" + Environment.NewLine + "\"" + key + "\"=\"" + value + "\"";
TextWriter tw = new StreamWriter(System.IO.Path.GetTempPath() + "GitExtensions.reg", false);
tw.Write(reg);
tw.Close();
GitCommands.GitCommands.RunCmd("regedit", "\"" + System.IO.Path.GetTempPath() + "GitExtensions.reg" + "\"");
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("GitExtensions has insufficient permisions to modify the registry." + Environment.NewLine + "Please add this key to the registry manually." + Environment.NewLine + "Path: " + root.ToString() + "\\" + subkey + Environment.NewLine + "Value: " + key + " = " + value);
}
}