Computer >> Computer tutorials >  >> Software >> Office

How to Automatically Uninstall All Previous Office Versions using OffScrub Script

To solve the problem of bulk MS Office update to the latest version on all user computers (Office 2016 should be deployed through SCCM and activated on Office 2016 KMS server), we needed to develop a simple script to automatically and correctly remove of any previously installed versions of Microsoft Office. This script should be used in tasks of automatic uninstall / installation of Office using SCCM packages.

Before installing a new Office version, it is recommended to remove any previously installed versions of MS Office (simultaneous use of different Office versions on a computer is supported, but not recommended due to potential problems). Therefore, there was a need to develop a script that would correctly uninstall any Office version previously installed on a PC.

OffScrub VBS Scripts

After considering several ways of uninstallation of previously installed Office versions, we stopped at using OffScrub scripts from the Microsoft Premier Support service. OffScrub scripts are included in the official EasyFix package. (The package of forced Office 2007 and 2010 uninstallation if it is not possible to uninstall them from the Control Panel.) To remove Office 2013 and 2016, another tool is used, O15CTRRemove.diagcab package, that also contains OffScrub scripts (see the note below).

OffScrub is a set of VBS scripts for automatic removal of Office products. These scripts allow you to completely clean the system from previously installed Office components, independent of its current operability. Here are the main advantages of using Offscrub to uninstall Office:

  1. The ability to uninstall the old Office version even if there are no or damaged original installation files or Office cache.
  2. User keys in the registry are not affected.
  3. Complete Office removal.
  4. Removal of all obsolete settings and all products (including Project, Visio, Visio Viewer).

Remove-PreviousOfficeInstalls.ps1 script from O15CTRRemove.diagcab package allows to detect the installed Office version and call Offscrub*.vbs for the corresponding Office version.

First of all, download FixIt from the official Microsoft website for those Office and Windows versions you are using in your infrastructure. You can download O15CTRRemove.diagcab package for different Office and Windows versions from this page (https://support.microsoft.com/en-us/kb/971179).

Important note! Earlier on this page there were links to both the EasyFix package and O15CTRRemove.diagcab. At the moment, there is only a link to the universal package O15CTRRemove.diagcab, which can be used to remove Office 2013/2016 on Window 7 SP1, Windows 8.1 and Windows 10. Also, early this year Offscrub scripts for new Office versions were in O15CTRRemove.diagcab, and now only PowerShell scripts are left in it. These (and other) Offscrub VBS scripts can now be obtained only from the official repository of Office developers on GitHub (OfficeDev).

In the following table I have collected the links to Microsoft packages to uninstall different Office versions in different OS versions.

Office Version Windows 7 Windows 8 Windows 10
Office 2003 MicrosoftFixit20054.mini.diagcab No
Office 2007 MicrosoftFixit20052.mini.diagcab No
Office 2010 MicrosoftFixit20055.mini.diagcab
Office 2013 File OffScrub_O15msi.vbs on GitHub
Office 2016 File OffScrub_O16msi.vbs on GitHub
Office 365/ Click-To-Run File OffScrubc2r.vbs on GitHub

How to Automatically Uninstall All Previous Office Versions using OffScrub Script

Download these files and save them to C:\tools\OfficeUninstall. *.diagcab files are the common archives in the CAB format, and you can unpack them using the expand command.

To make it easier, create a separate directory for each Office version:

set OFFICEREMOVE=C:\tools\OfficeUninstall\
md "%OFFICEREMOVE%\2003"
md "%OFFICEREMOVE%\2007"
md "%OFFICEREMOVE%\2010"
md "%OFFICEREMOVE%\2013"
md "%OFFICEREMOVE%\2016"
md "%OFFICEREMOVE%\O365"

Unpack only VBS files from the downloaded diagcab archives.

expand -i "%OFFICEREMOVE%\MicrosoftFixit20054.mini.diagcab" -f:OffScrub*.vbs "%OFFICEREMOVE%\2003"
expand -i "%OFFICEREMOVE%\MicrosoftFixit20052.mini.diagcab" -f:OffScrub*.vbs "%OFFICEREMOVE%\2007"
expand -i "%OFFICEREMOVE%\MicrosoftFixit20055.mini.diagcab" -f:OffScrub*.vbs "%OFFICEREMOVE%\2010"

And copy the VBS files for new Office versions downloaded from GitHub into the same directories.

move /y "%OFFICEREMOVE%\OffScrub_O15msi.vbs" "%OFFICEREMOVE%\2013"
move /y "%OFFICEREMOVE%\OffScrub_O16msi.vbs" "%OFFICEREMOVE%\2016"
move /y "%OFFICEREMOVE%\OffScrubc2r.vbs" "%OFFICEREMOVE%\O365"

How to Automatically Uninstall All Previous Office Versions using OffScrub Script

Thus, we have got the following VBS files:

  • 2003\OffScrub03.vbs
  • 2007\OffScrub07.vbs
  • 2010\OffScrub10.vbs
  • 2013\OffScrub_O15msi.vbs
  • 2016\OffScrub_O16msi.vbs
  • O365\OffScrubc2r.vbs

You can get the list of available arguments for any OffScrub VBS script as follows:

OffScrub_O16msi.vbs /?

Microsoft Customer Support Service – Office 2016 MSI Removal Utility
OffScrub_O16msi.vbs helps to remove Office 2016 MSI Server and Client products
Usage: OffScrub_O16msi.vbs [List of config ProductIDs] [Options]

How to Automatically Uninstall All Previous Office Versions using OffScrub Script

Running OffScrub VBS Scripts Using SCCM

In order the Office uninstallation script to work correctly on Windows x64 if run by the 32-bit Configuration Manager client, you should run the corresponding cscript.exe version. So to run the scenarios on a 64-bit system, you need to run cscript.exe from C:\Windows\SysWOW64.

You can achieve this using NativeCScript.cmd script:

@echo off
if "%PROCESSOR_ARCHITEW6432%"=="AMD64" (
"%SystemRoot%\Sysnative\cscript.exe" %*
) else (
"%SystemRoot%\System32\cscript.exe" %*
)

You can download a ready-to-use archive with all necessary files from our website: OfficeRemova-OffScrubl.zip (1.4 MB)

Office Removal Scripts

Office 2003 Removal Utility

The command to manually start the script for the complete removal of Office 2003 components from the computer looks like this:

Cscript.exe "%OFFICEREMOVE%\2003\OffScrub03.vbs” ALL /Quiet /NoCancel /Force /OSE

How to Automatically Uninstall All Previous Office Versions using OffScrub Script

If the uninstallation task is run as an SCCM task, the removal program may look as follows:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2003\OffScrub03.vbs" ALL /Quiet /NoCancel /Force /OSE"

Office 2007 Removal Utility

The command to completely remove Office 2007 components:

Cscript.exe "%OFFICEREMOVE%\2007\OffScrub07.vbs” ALL /Quiet /NoCancel /Force /OSE

To run the script using the SCCM task:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2007\OffScrub07.vbs" ALL /Quiet /NoCancel /Force /OSE"

Office 2010 Removal Utility

The command to completely uninstall Microsoft Office 2010:

Cscript.exe "%OFFICEREMOVE%\2010\OffScrub10.vbs” ALL /Quiet /NoCancel /Force /OSE

When running in the Configuration Manager:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2010\OffScrub10.vbs" ALL /Quiet /NoCancel /Force /OSE"

Office 2013 Removal Utility

The command to completely remove Office 2013 MSI products:

Cscript.exe "%OFFICEREMOVE%\2013\OffScrub_O15msi.vbs” ALL /Quiet /NoCancel /Force /OSE

To run the script using the SCCM task:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2013\OffScrub_O15msi.vbs" ALL /Quiet /NoCancel /Force /OSE"

Office 2016 Removal Utility

The command to run the OffScrub script for the complete removal of Office 2016 MSI products on the current computer

Cscript.exe "%OFFICEREMOVE%\2016\OffScrub_O16msi.vbs” ALL /Quiet /NoCancel /Force /OSE

You can run Office 2016 uninstallation from the SCCM package using this command:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2016\OffScrub_O16msi.vbs" ALL /Quiet /NoCancel /Force /OSE"

Script to Uninstall Office Click to Run or Office 365

To remove Office Click to Run or Office 365 package, run this command:

Cscript.exe "%OFFICEREMOVE%\C2R\OffScrubc2r.vbs” ALL /Quiet /NoCancel /Force /OSE

To run the script using the SCCM task:

"%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "C2R\OffScrubc2r.vbs" ALL /Quiet /NoCancel /OSE"

Automatically Detecting the Version of MS Office

Remove-PreviousOfficeInstalls.ps1 is a PowerShell script from the Remove-PreviousOfficeInstalls project on Git that automatically detects the version and activation status of installed MS Office on a computer and calls the corresponding OffScrub scripts. With certain modifications, it can be used in the scenarios of automatic Office removal.