public bool Remove() { bool FilesRemoved = false; string[] allfiles = FindAllSuperfishFiles(); if ((null != allfiles) && (0 < allfiles.Length)) { bool ProblemDeletingFile = false; // Try to stop/kill AND remove Superfish services and processes (so that the files can be deleted) ApplicationUtility.StopAllSuperfishProcesses(); ApplicationUtility.RemoveAllSuperfishServices(); Logging.Logger.Log(Logging.LogSeverity.Information, "Deleting Superfish files: "); foreach (string file in allfiles) { Logging.Logger.Log(Logging.LogSeverity.Information, " " + file); try { if (System.IO.Directory.Exists(file)) { System.IO.Directory.Delete(file, true); if (System.IO.Directory.Exists(file)) { ProblemDeletingFile = true; Logging.Logger.Log(Logging.LogSeverity.Error, " Error deleting " + file); System.IO.Directory.Delete(file, true); } } else if (System.IO.File.Exists(file)) { System.IO.File.Delete(file); if (System.IO.File.Exists(file)) { ProblemDeletingFile = true; Logging.Logger.Log(Logging.LogSeverity.Error, " Error deleting " + file); System.IO.File.Delete(file); } } else { // In case duplicate files were added to the list and removed earlier Logging.Logger.Log(Logging.LogSeverity.Information, " Already deleted " + file); } } catch (Exception ex) { ProblemDeletingFile = true; Logging.Logger.Log(Logging.LogSeverity.Error, " Exception deleting " + file + " - " + ex.ToString()); } } FilesRemoved = (!ProblemDeletingFile); } return(FilesRemoved); }
static int SilentMode() { int ExitCode = 0; Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check"); var appChecker = new Utilities.ApplicationUtility(); Utilities.FixResult appResult = appChecker.RemoveItem(); if (appResult.DidFail) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: ERROR"); } else if (appResult.DidExist) { if (appResult.WasRemoved) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Found & Removed"); } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Found - ERROR Removing"); ExitCode = 1; //ExitCode = (0 == ExitCode) ? 1 : 0; } } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Application: Not found"); } var certChecker = new Utilities.CertificateUtility(); Utilities.FixResult certResult = certChecker.RemoveItem(); if (certResult.DidFail) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: ERROR"); } else if (certResult.DidExist) { if (certResult.WasRemoved) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Found & Removed"); } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Found - ERROR Removing"); ExitCode = (0 == ExitCode) ? 2 : 0; } } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Certificates: Not found"); } var certChecker2 = new Utilities.MozillaCertificateUtility(); Utilities.FixResult certResult2 = certChecker2.RemoveItem(); if (certResult2.DidFail) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: ERROR"); } else if (certResult2.DidExist) { if (certResult2.WasRemoved) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Found & Removed"); } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Found - ERROR Removing"); ExitCode = (0 == ExitCode) ? 3 : 0; } } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Mozilla Certificates: Not found"); } var regChecker = new Utilities.RegistryUtility(); Utilities.FixResult regResult = regChecker.RemoveItem(); if (regResult.DidFail) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: ERROR"); } else if (regResult.DidExist) { if (regResult.WasRemoved) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Found & Removed"); } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Found - ERROR Removing"); ExitCode = (0 == ExitCode) ? 4 : 0; } } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Registry Entries: Not found"); } var fileChecker = new Utilities.FilesDetector(); Utilities.FixResult fileResult = fileChecker.RemoveItem(); if (fileResult.DidFail) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: ERROR"); } else if (fileResult.DidExist) { if (fileResult.WasRemoved) { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Found & Removed"); } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Found - ERROR Removing"); ExitCode = (0 == ExitCode) ? 5 : 0; } } else { Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Files: Not found"); } Logging.Logger.Log(Logging.LogSeverity.Information, "Superfish Removal Check Complete"); return(ExitCode); }