private bool InstallOrUninstall(IList <string> installerIds, IElevationContext elevationContext, IProgressMonitor progressMonitor,
                                        InstallerOperation operation)
        {
            if (progressMonitor == null)
            {
                throw new ArgumentNullException("progressMonitor");
            }

            var filteredInstallerHandles = FilterInstallers(installerIds);

            using (progressMonitor.BeginTask(operation == InstallerOperation.Install ? "Installing components." : "Uninstalling components.",
                                             filteredInstallerHandles.Count + 1))
            {
                if (progressMonitor.IsCanceled)
                {
                    return(false);
                }

                if (elevationContext != null ||
                    elevationManager.HasElevatedPrivileges ||
                    !IsElevationRequired(filteredInstallerHandles))
                {
                    return(InstallOrUninstallWithElevationContext(filteredInstallerHandles, elevationContext, progressMonitor, operation));
                }

                return(elevationManager.TryElevate(
                           newElevationContext => InstallOrUninstallWithElevationContext(filteredInstallerHandles, newElevationContext, progressMonitor, operation),
                           "Administrative access required to install or uninstall certain components."));
            }
        }
        /// <inheritdoc />
        public override int Execute(UtilityCommandContext context, object arguments)
        {
            context.Logger.Log(LogSeverity.Important, "Resetting the installation id.\nThe plugin list will be refreshed the next time a Gallio application is started.");

            bool result = elevationManager.TryElevate(elevationContext =>
            {
                context.ProgressMonitorProvider.Run(progressMonitor =>
                {
                    elevationContext.Execute(ResetInstallationIdElevatedCommand.ElevatedCommandId, null, progressMonitor);
                });

                return(true);
            }, "Administrative access required to reset the installation id.");

            return(result ? 0 : 1);
        }