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?

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
Silipen MakX
  • 13
  • 1
  • 4
  • Did you remove Office properly? (Control Panel, Programs and Features? Office updates go away (for me, on all machines) when done this way. – John May 01 '20 at 13:42
  • I first used the setup.exe in the installation folder to remove my Office 2016. Then I followed the Step 2 (Manually remove an MSI installation of Office) of this article https://support.office.com/en-us/article/manually-uninstall-office-4e2904ea-25c8-4544-99ee-17696bb3027b and deleted some folders. That's all the things I have done. – Silipen MakX May 01 '20 at 14:42
  • Okay.. After a few minutes I found there is no more Office updates, you are right. Thanks a lot. It works me so hard on finding a PowerShell solution and finally turns out that it needn't require such amount of work. – Silipen MakX May 01 '20 at 14:53
  • I will post my answer and hopefully you will find it helpful along with the powershell answer – John May 01 '20 at 15:05

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
  • 455,459
  • 31
  • 526
  • 924
  • Well it comes up to an error message 'The update could not be uninstalled because the request did not originate from a WSUS server', I have encountered this error message for several times and don't know how to solve it... – Silipen MakX May 01 '20 at 14:33
  • Tries: (1) Replace `$Installer = $Session.CreateUpdateInstaller()` by the line `$Installer = New-Object -ComObject Microsoft.Update.Installer`. (2) Check under registry key `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU` for a value named `UseWuServer`, if set to 1 then set it to 0. If it doesn't exist, then create it as 0. I hope you are running as Admin. – harrymc May 01 '20 at 15:57
  • Since I found the updates were gone and no longer needed to use PowerShell, I solved my problem. Anyway thanks for that. – Silipen MakX May 02 '20 at 01:42
  • How did you remove Office initially if not through Programs and Features? Evidently, whatever you did wasn't a full uninstall, but I'm puzzled as to what it was. – harrymc May 02 '20 at 08:32
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.

John
  • 46,167
  • 4
  • 33
  • 54