Beispiel #1
0
        /// <summary>
        /// Load a list silently from filename
        /// </summary>
        /// <param name="filename">Filename of the list</param>
        public void LoadUninstallList(string filename)
        {
            var result = UninstallList.ReadFromFile(filename);

            CurrentListFilename = filename;
            uninstallListEditor1.CurrentList = result;
        }
Beispiel #2
0
 private void openFileDialog_FileOk(object sender, CancelEventArgs e)
 {
     try
     {
         CurrentList.AddItems(UninstallList.ReadFromFile(openFileDialog.FileName).Filters);
         PopulateList();
     }
     catch (Exception ex)
     {
         PremadeDialogs.GenericError(ex);
         e.Cancel = true;
     }
 }
        /// <summary>
        /// Load a list silently from filename
        /// </summary>
        /// <param name="fileName">Filename of the list</param>
        public void LoadUninstallList(string fileName)
        {
            try
            {
                var result = UninstallList.ReadFromFile(fileName);

                CurrentListFileName = fileName;
                uninstallListEditor1.CurrentList = result;
                UnsavedChanges = false;
            }
            catch (Exception ex)
            {
                PremadeDialogs.GenericError(ex);
            }
        }
        /// <summary>
        /// Load a list silently from filename
        /// </summary>
        /// <param name="fileName">Filename of the list</param>
        public void LoadUninstallList(string fileName)
        {
            try
            {
                var result = UninstallList.ReadFromFile(fileName);

                CurrentListFileName = fileName;
                uninstallListEditor1.CurrentList = result;
                UnsavedChanges = false;
            }
            catch (SecurityException ex)
            {
                PremadeDialogs.GenericError(ex);
            }
            catch (Exception ex)
            {
                PremadeDialogs.GenericError("File is not an uninstall list or it can't be opened",
                                            "Please note that uninstall lists are saved in the \"Advanced filtering\" view, not by exporting. Lists should have the .bcul extension.\n\nError message: " + ex.Message);
            }
        }
Beispiel #5
0
        private static int ProcessUninstallCommand(string[] args)
        {
            if (args.Length < 1)
            {
                return(ShowInvalidSyntaxError("Missing path argument"));
            }

            if (!File.Exists(args[0]))
            {
                return(ShowInvalidSyntaxError("Invalid path or missing list file"));
            }

            UninstallList list;

            try
            {
                list = UninstallList.ReadFromFile(args[0]);
                if (list == null || list.Filters.Count == 0)
                {
                    throw new IOException("List is empty");
                }
            }
            catch (SystemException ex)
            {
                return(ShowInvalidSyntaxError(
                           $"Invalid or damaged uninstall list file - \"{args[0]}\"\nError: {ex.Message}\n"));
            }

            var isVerbose    = args.Any(x => x.Equals("/V", StringComparison.OrdinalIgnoreCase));
            var isQuiet      = args.Any(x => x.Equals("/Q", StringComparison.OrdinalIgnoreCase));
            var isUnattended = args.Any(x => x.Equals("/U", StringComparison.OrdinalIgnoreCase));

            if (isUnattended)
            {
                Console.WriteLine("WARNING: Running in unattended mode. To abort press Ctrl+C or close the window.");
            }

            return(RunUninstall(list, isQuiet, isUnattended, isVerbose));
        }
 public void LoadUninstallList(UninstallList list)
 {
     CurrentListFileName = string.Empty;
     uninstallListEditor1.CurrentList = list;
 }
Beispiel #7
0
        private static int RunUninstall(UninstallList list, bool isQuiet, bool isUnattended, bool isVerbose)
        {
            Console.WriteLine("Starting bulk uninstall...");
            var apps = QueryApps(isQuiet, isUnattended, isVerbose);

            apps = apps.Where(a => list.TestEntry(a) == true).OrderBy(x => x.DisplayName).ToList();

            if (apps.Count == 0)
            {
                Console.WriteLine("No applications matched the supplied uninstall list.");
                return(0);
            }

            Console.WriteLine("{0} application(s) were matched by the list: {1}", apps.Count,
                              string.Join("; ", apps.Select(x => x.DisplayName)));

            Console.WriteLine("These applications will now be uninstalled PERMANENTLY.");

            if (!isUnattended)
            {
                Console.WriteLine("Do you want to continue? [Y]es/[N]o");
                if (Console.ReadKey(true).Key != ConsoleKey.Y)
                {
                    return(CancelledByUser());
                }
            }

            Console.WriteLine("Setting-up for the uninstall task...");
            var targets = apps.Select(a => new BulkUninstallEntry(a, a.QuietUninstallPossible, UninstallStatus.Waiting))
                          .ToList();
            var task = UninstallManager.CreateBulkUninstallTask(targets,
                                                                new BulkUninstallConfiguration(false, isQuiet, false, true, true));
            var isDone = false;

            task.OnStatusChanged += (sender, args) =>
            {
                ClearCurrentConsoleLine();

                var running  = task.AllUninstallersList.Count(x => x.IsRunning);
                var waiting  = task.AllUninstallersList.Count(x => x.CurrentStatus == UninstallStatus.Waiting);
                var finished = task.AllUninstallersList.Count(x => x.Finished);
                var errors   = task.AllUninstallersList.Count(x => x.CurrentStatus == UninstallStatus.Failed ||
                                                              x.CurrentStatus == UninstallStatus.Invalid);
                Console.Write("Running: {0}, Waiting: {1}, Finished: {2}, Failed: {3}",
                              running, waiting, finished, errors);

                if (task.Finished)
                {
                    isDone = true;
                    Console.WriteLine();
                    Console.WriteLine("Uninstall task Finished.");

                    foreach (var error in task.AllUninstallersList.Where(x =>
                                                                         x.CurrentStatus != UninstallStatus.Completed && x.CurrentError != null))
                    {
                        Console.WriteLine("Error: {0} - {1}", error.UninstallerEntry.DisplayName,
                                          error.CurrentError.Message);
                    }
                }
            };
            task.Start();

            while (!isDone)
            {
                Thread.Sleep(250);
            }

            return(0);
        }