public bool Equals(Update update) { bool results = false; if ((this.TopPatchId != null) && (update.TopPatchId != null)) { if (this.TopPatchId.Equals(update.TopPatchId)) { results = true; } } else if ((this.VendorId != null) && (update.VendorId != null)) { if ((this.VendorId.Equals(update.VendorId)) && (this.Name.Equals(update.Name))) { results = true; } } else { if (this.Name.Equals(update.Name)) { results = true; } } return results; }
public UninstallerResults Uninstall(Update update) { UninstallerResults results = new UninstallerResults(); if ((winVersion == NTVersion.XP) || (winVersion == NTVersion.Server2003)) { results = WinNT51_52Procedure(update); } else if ((winVersion == NTVersion.VistaServer2008)) { results = WinNT60Procedure(update); } else if (winVersion == NTVersion.SevenServer2008R2) { results = WinNT61Procedure(update); } return results; }
/// <summary> /// Convert an IUpdate (MS Update model) object to an Update (TopPatch model). /// </summary> /// <param name="iUpdate"></param> /// <returns></returns> private Update ConvertToUpdate(IUpdate iUpdate, IUpdateHistoryEntryCollection history = null) { Update tpUpdate = new Update { Name = iUpdate.Title, VendorId = iUpdate.Identity.UpdateID, FileSize = iUpdate.MaxDownloadSize.ToString(), Description = iUpdate.Description, SupportURL = (iUpdate.MoreInfoUrls.Count <= 0) ? String.Empty : iUpdate.MoreInfoUrls[0], Severity = GetTopPatchSeverity(iUpdate.MsrcSeverity), KB = GetKbString(iUpdate.Title), // Get the KB from the title string. // Getting the date installed of an update is tricky. // Have to go through leaps and bounds. Thank you Microsoft!! DateInstalled = GetDateInstalled(history, iUpdate.Identity.UpdateID), DatePublished = iUpdate.LastDeploymentChangeTime.ToShortDateString(), IsHidden = iUpdate.IsHidden, IsInstalled = iUpdate.IsInstalled }; tpUpdate.TopPatchId = Utils.TopPatch.GenerateTopPatchId(tpUpdate); return tpUpdate; }
/// <summary> /// Here begins the procedure to uninstall updates on Windows 7 & Windows Server 2008 R2. (6.1) /// </summary> /// <param name="update">Update to uninstall.</param> private UninstallerResults WinNT61Procedure(Update update) { // TODO: NOT FULLY BAKED!!!! Doesn't check registry for updates that could be there. List<QfeData> qfeList = QueryWMIHotfixes(); UninstallerResults temp = new UninstallerResults(); foreach (QfeData qfe in qfeList) { if (qfe.HotFixID.Equals(update.KB)) { return WusaProcess(update.KB); } } return temp; }
/// <summary> /// Here begins the procedure to uninstall updates on Windows Vista & Windows Server 2008. /// </summary> /// <param name="update">Update to uninstall.</param> private UninstallerResults WinNT60Procedure(Update update) { UninstallerResults results = new UninstallerResults(); AgentSettings.Log("In WinNT60Procedure."); string cabFilePath = FindCabFile(update.KB); if (cabFilePath == null) { results = ProcessUninstallerResults(WindowsExitCode.UpdateNotFound); return results; } // Arguments used by "pkgmgr.exe" string noGUI = "/quiet"; string noRestart = "/norestart"; // /up is the uninstall command. /s is a temp sandbox directory where to unpack the CAB file. string arguments = String.Format(@"/m:{0} /up /s:{1} {2} {3}", cabFilePath, Path.Combine(System.IO.Path.GetTempPath(), update.KB), noGUI, noRestart); WindowsExitCode exitCode = WindowsProcess("pkgmgr.exe", arguments); results = ProcessUninstallerResults(exitCode); return results; }
/// <summary> /// Here begins the procedure to uninstall updates on Windows XP & Windows Server 2003 & R2. /// </summary> /// <param name="update">Update to uninstall.</param> private UninstallerResults WinNT51_52Procedure(Update update) { UninstallerResults results; // Arguments used by "spuninst.exe" string noGUI = "/quiet"; string noRestart = "/norestart"; string arguments = String.Format("{0} {1}", noGUI, noRestart); // Process that's going to run the uninstalltion application Dictionary<string, string> keys = ParseWinNT51_52Keys(); if (!keys.ContainsKey(update.KB)) { results = ProcessUninstallerResults(WindowsExitCode.UpdateNotFound); return results; } string spuninstProcess = keys[update.KB].ToString(); WindowsExitCode exitCode = WindowsProcess(spuninstProcess, arguments); results = ProcessUninstallerResults(exitCode); return results; }