Пример #1
0
 public static void Main(string[] args)
 {
     if (args != null && args.Length > 0 && args[0] == "saveSystemPath")
     {
         BatchMode.SavePathFromTempFile();
     }
     else
     {
         var app = new App();
         app.Run(new MainWindow());
     }
 }
Пример #2
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items));
     if (PathType == PathType.User)
     {
         PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items));
     }
     else
     {
         BatchMode.UseBatchModeAsAdmin(Items);
     }
     DisabledItems.SaveDisabledItems(PathType, Items);
     PathBox.Focus();
 }
Пример #3
0
        public static void UseBatchModeAsAdmin(IEnumerable <PathEntry> items)
        {
            BatchMode.SavePathToTempFile(items);
            var exeName   = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            var startInfo = new ProcessStartInfo(exeName);

            startInfo.Verb      = "runas";
            startInfo.Arguments = "saveSystemPath";
            try
            {
                Process.Start(startInfo);
            }
            catch
            {
                File.Delete(TempFileName);
                MessageBox.Show("Необходимы права администратора для редактирования PATH." +
                                "Изменения не сохранены.");
            }
        }