public void Uninstall(UninstallInfo uninstallInfo) { var toRemove = FindComponentsToRemove(uninstallInfo.GetPublicKeyToken()); Console.WriteLine("Components to remove:"); toRemove.ForEach(Console.WriteLine); Console.WriteLine(); var steps = new List <IUninstallStep> { new RemoveFiles(), new RemoveStartMenuEntry(uninstallInfo), new RemoveRegistryKeys(_registry, uninstallInfo), new RemoveUninstallEntry(uninstallInfo) }; steps.ForEach(s => s.Prepare(toRemove)); steps.ForEach(s => s.PrintDebugInformation()); steps.ForEach(s => s.Execute()); steps.ForEach(s => s.Dispose()); }
private void button1_Click(object sender, EventArgs e) { DialogResult result1 = MessageBox.Show("Isso pode levar alguns minutos. Por favor, aguarde o aviso de desinstalação concluída.", "Aviso!", MessageBoxButtons.OKCancel); if (result1 == DialogResult.OK) { //VARIABLES string vlibrasFolderPath = Environment.GetEnvironmentVariable("PATH_VLIBRAS", EnvironmentVariableTarget.User); string resetEnvVarPath = Path.Combine(vlibrasFolderPath, "ResetEnvVar.exe"); string mainFolderPath = Directory.GetParent(vlibrasFolderPath).FullName; // %LOCALAPPDATA%/VLibras/ string startMenuFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs); string lavidStartMenuFolderPath = startMenuFolderPath + @"\LAVID-UFPB"; // startMenuFolderPath/LAVID-UFPB/ //DELETING SHORTCUTS try { object shDesktop = (object)"Desktop"; WshShell shell = new WshShell(); //Deleting shortcut on Desktop string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\VLibras.lnk"; System.IO.File.Delete(shortcutAddress); //Deleting start menu folder Directory.Delete(lavidStartMenuFolderPath, true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Remoção de atalho", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } //DELETING ENVIRONMENT VARIABLES ProcessStartInfo resetInfo = new ProcessStartInfo(); resetInfo.FileName = resetEnvVarPath; resetInfo.Arguments = "-u"; resetInfo.WindowStyle = ProcessWindowStyle.Hidden; resetInfo.CreateNoWindow = true; Process.Start(resetInfo); Close(); //DELETING EXTRACTED FOLDERS try { deleteDirectory(mainFolderPath); } catch (Exception ex) { MessageBox.Show(ex.Message, "Remoção de conteúdo extraído", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } //DELETING CLICKONCE'S VERSIONS AND REGISTRIES try { var uninstallInfo = UninstallInfo.Find("Atualizador VLibras"); if (uninstallInfo != null) { var uninstaller = new Uninstaller(); uninstaller.Uninstall(uninstallInfo); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Desinstalação do atualizador", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } //UNINSTALL FINISHED MessageBox.Show(@"Desinstalação concluída.", @"Operação concluída."); //DELETE ITSELF IN 3 SECONDS ProcessStartInfo info = new ProcessStartInfo(); info.FileName = @"cmd.exe"; string dir = Directory.GetCurrentDirectory(); info.Arguments = @"/C ping 1.1.1.1 -n 1 -w 3000 > Nul & cd .. & rmdir /s /q " + dir; // Del DesinstaladorVLibras.exe"; info.WindowStyle = ProcessWindowStyle.Hidden; info.CreateNoWindow = true; Process.Start(info); Close(); } }
public RemoveRegistryKeys(ClickOnceRegistry registry, UninstallInfo uninstallInfo) { _registry = registry; _uninstallInfo = uninstallInfo; }
public RemoveUninstallEntry(UninstallInfo uninstallInfo) { _uninstallInfo = uninstallInfo; }
public RemoveStartMenuEntry(UninstallInfo uninstallInfo) { _uninstallInfo = uninstallInfo; }