1

Recently I removed my Office 2016, and My PC remains so much Office update patchs.


enter image description here


From this question's answer, I learnt to use the Windows Update API commands to search the existing Office update patches. After spending a vast amount of time, I can't find any viable uninstalling command of Windows Update API. So how to perform the uninstalling step after I found all existing Office update patches?

2 Answers2

0

The PowerShell script below is adapted from the post
PowerShell: How to find and uninstall a MS Office Update.

I have not tested it, so I suggest to at least create a System Restore point before trying it, and to debug it carefully while commenting out the command that does the actual uninstall: $Installer.Uninstall() and the command following it.

$Session = New-Object -ComObject Microsoft.Update.Session

$Collection = New-Object -ComObject Microsoft.Update.UpdateColl
$Installer = $Session.CreateUpdateInstaller()
$Searcher = $Session.CreateUpdateSearcher()

$Searcher.QueryHistory(0, $Searcher.GetTotalHistoryCount()) | 
    Where-Object { $_.Title -match 'Update for Microsoft Office' } |
    ForEach-Object {
        Write-Verbose "Found update history entry $($_.Title)"
        $SearchResult = $Searcher.Search("UpdateID='$($_.UpdateIdentity.UpdateID)' and RevisionNumber=$($_.UpdateIdentity.RevisionNumber)")
        Write-Verbose "Found $($SearchResult.Updates.Count) update entries"
        if ($SearchResult.Updates.Count -gt 0) {
            $Installer.Updates = $SearchResult.Updates
            $Installer.Uninstall()
            $Installer | Select-Object -Property ResultCode, RebootRequired, Exception
            # result codes: http://technet.microsoft.com/en-us/library/cc720442(WS.10).aspx
        }
    }
harrymc
  • 498,455
0

Try a full removal of Office (Control Panel, Programs and Features). Office updates go away (for me, on all machines) when done this way.