private void AppendToPath_Click(object sender, RoutedEventArgs e)
{
try
{
RegistryKey HKCU_ENVIRONMENT = Registry.CurrentUser.CreateSubKey("Environment");
string BendExePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string bendDirectory = System.IO.Path.GetDirectoryName(BendExePath);
string currentPath;
if (HKCU_ENVIRONMENT.GetValue("Path") != null)
{
currentPath = HKCU_ENVIRONMENT.GetValue("Path").ToString();
if (currentPath.IndexOf(bendDirectory) >= 0)
{
// We are already in the path nothing to do here.
throw new Exception();
}
}
else
{
currentPath = "";
}
currentPath = bendDirectory + ";" + currentPath;
HKCU_ENVIRONMENT.SetValue("Path", currentPath);
}
catch
{
}
}