private static bool InstallOrUninstallWithElevationContext(IEnumerable <ComponentHandle <IInstaller, InstallerTraits> > installerHandles, IElevationContext elevationContext, IProgressMonitor progressMonitor, InstallerOperation operation) { foreach (var installerHandle in installerHandles) { if (progressMonitor.IsCanceled) { return(false); } IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1); if (elevationContext != null && installerHandle.GetTraits().RequiresElevation) { elevationContext.Execute(InstallerElevatedCommand.ElevatedCommandId, new InstallerElevatedCommand.Arguments(installerHandle.Id, operation), subProgressMonitor); } else { IInstaller installer = installerHandle.GetComponent(); if (operation == InstallerOperation.Install) { installer.Install(progressMonitor.CreateSubProgressMonitor(1)); } else { installer.Uninstall(progressMonitor.CreateSubProgressMonitor(1)); } } } return(true); }
/// <summary> /// Starts the actual uninstall process. /// </summary> public async void Uninstall() { // If "Uninstall()" was already run before, this method gets called again when // the user hits the "finish" button. If that's the case, just drop out. if (this.UninstallFinished) { Cancel(); } // If we get here, we're about to launch the actual uninstall Progress <Tuple <int, string> > progress = new Progress <Tuple <int, string> >((x) => { Dispatcher.UIThread.Post(() => { this.ProgressPercentage = x.Item1; this.UninstallLog = this.UninstallLog + Environment.NewLine + x.Item2; }); }); this.CanUninstall = false; await _installer.Uninstall(progress, dryRun : false); this.UninstallFinished = true; this.CanUninstall = true; }
public string Install() { if (_installer.IsPartiallyInstalled) { _installer.Uninstall(); } if (_installer.IsInstalled == false) { return(_installer.Install()); } return(null); }
protected override void ProcessRecord() { base.ProcessRecord(); var logger = new CommandLogger(this); var context = new InstallerContext(Parameters, logger); IInstaller installer = InstallerFactory.Create(); try { installer.Uninstall(context); } catch (Exception exception) { logger.Error(exception); } }
public void Uninstall() { _installer.Uninstall(); }