Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / MS Office / How to Completely Uninstall Previous Versions of Office with Removal Scripts

June 8, 2023 MS OfficeSCCMWindows 10Windows Server 2016

How to Completely Uninstall Previous Versions of Office with Removal Scripts

Before installing a new version of Microsoft Office on a computer, it is recommended to remove all previous versions of Office (simultaneous use of different versions of Office products on the same computer is supported, but not recommended due to potential problems). In this article, we’ll look at several tools and scripts for automatically removing any previous versions of Microsoft Office installed on the computer. You can use these scripts to silently uninstall Office on user computers through SCCM, Intune, GPO, or other deployment tools.

Contents:
  • Uninstall Office Automatically with Microsoft SaRa Tool
  • Removing Previous MSI versions of Office using the Office Deployment Tool
  • OffScrub: VBS Scripts to Completely Remove MS Office
  • Uninstalling Microsoft.Office.Desktop App with PowerShell

Uninstall Office Automatically with Microsoft SaRa Tool

Microsoft Support and Recovery Assistant (Microsoft SaRA, https://aka.ms/SaRA-FirstScreen) is a tool for diagnosing and fixing Microsoft Office errors (including Office 365, Microsoft 365, Outlook, Teams, etc.). Microsoft SaRa provides users a simple GUI to fix common Office errors, allows to install, check activation status, and completely delete MS Office. The MSFT SaRa tool can be used to uninstall previous Office products on a single computer.

Microsoft SaRA (Microsoft Support and Recovery Assistant) unisntall office suite products

In addition to the graphical version of SaRa, there is also the console SaRA_CommandLine tool, which can be used to uninstall the Office suite products from the command prompt. Accordingly, you can use it in your automation scripts. All versions of Windows, from Windows 7 (with the .Net Framework 4.5 installed) to Windows 10 and 11 are supported.

You can use the SaRA console utility to uninstall the following Office versions: Office 365, Office 2021, 2019, 2016, 2013, and 2010. Both MSI and Click-to-Run (C2R) removal of Office distributions is supported.

Let’s see how to use SaRACmd to uninstall any version of Office

  1. Download the latest available version of SaRACmd https://aka.ms/SaRA_CommandLineVersionFiles (17.00.8256.000);
  2. Extract the archive to a local folder;
  3. Run a command prompt as an administrator and change to the SaRACmd directory: CD C:\Tools\SaRACmd
  4. To remove all versions of Office that are installed on the computer, run the command: SaRAcmd.exe -S OfficeScrubScenario –AcceptEula -Officeversion All
  5. If you need to uninstall a specific version of MS Office (for example, only MS Office 2013), use the following command: SaRAcmd.exe -S OfficeScrubScenario -AcceptEula -Officeversion 2013
  6. The SaRAcmd tool returns an error code when completed. For example, if the removal was successful, the following message will appear:
    00: Successfully completed this scenario. We recommend you restart the computer to finish any remaining cleanup tasks. Scenario finished with exit code: [0].

    saracmd remove office product from command prompt

    You can specify the path to the directory where SaRAcmd should write logs: -LogFolder <Output Path>.

For example, the SaRAcmd returned an error on my computer:

06: Office programs are running. Please close all open Office programs and then re-run this scenario. Scenario finished with exit code: [6].

In my case, the removal was prevented by the MS Teams client set to start automatically (perhaps the same problem with the Teams Chat client built-in in Windows 11).

Therefore, you must kill all running Office processes before executing the uninstall command. You can terminate MS Office application processes by using the PowerShell Stop-Process command:

Stop-Process -Name winword.exe -Confirm
Stop-Process -Name excel.exe -Confirm

Etc.

The following Office processes need to be terminated: lync, winword, excel, msaccess, mstore, infopath, setlang, msouc, ois, onenote, outlook, powerpnt, mspub, groove, visio, winproj, graph, teams.

Or using the taskkill command:
taskkill /f /im excel.exe
taskkill /f /im teams.exe
...

Note that under the hood, SaRAcmd runs the OffScrubC2R.vbs script to uninstall Office Click To Run (C2R) products. This can be seen in the task manager by the cscript.exe process, which executes the OffScrubC2R.vbs file from %UserProfile%\AppData\Local\Temp.

OffScrub scripts are described below in the next section of the article.

offscrubc2r vbs script

You can use the SaRAcmd tool to uninstall Office on remote computers via PowerShell Remoting (Enter-PSSession or Invoke-Command cmdlets).

Removing Previous MSI versions of Office using the Office Deployment Tool

If you use the Microsoft Office Deployment Tool (ODT) to install C2R versions of Office 2019, 2021, or Microsoft 365 Apps on computers, you can uninstall previous MSI versions of Office during installation. To do this, add the RemoveMSI parameter to the configuration.xml config file.

Previously, we showed you how to deploy MS Office 2019 using ODT in an enterprise environment.

ODT configuration file example:

<Configuration>
<Add OfficeClientEdition="64" Channel="Current" >
<Product ID="O365ProPlusRetail">
<Language ID="en-us" />
</Product>
</Add>
<RemoveMSI />
</Configuration>

The RemoveMSI parameter specifies removing all versions of MS Office (2007, 2010, 2013, 2016), as well as Project, Visio, Project installed using the Windows Installer (MSI).

OffScrub: VBS Scripts to Completely Remove MS Office

OffScrub is a set of VBS scripts for automatically removing Microsoft Office products. These scripts allow you to completely clean the system from previously installed Office components, regardless of its current operability/health. These VBS scripts are widely used by Microsoft Premier Support (PFE). The Offscrub scripts are now deprecated, but you can use them in your scripts to uninstall all older versions of Office.

OffScrub scripts are currently available in the archived GitHub repository of Office developers: https://github.com/OfficeDev/Office-IT-Pro-Deployment-Scripts/tree/master/Office-ProPlus-Deployment/Remove-PreviousOfficeInstalls

Here are the main advantages of using Offscrub to uninstall Office:

  • Allows to uninstall an old Office version even if the source installation files or the Office cache are missing or corrupted;
  • User keys in the registry are not affected;
  • Provides complete Office removal;
  • Remove obsolete settings and all products (including Project, Visio, Visio Viewer).

remove previous office installs with vbs and powershell scripts

How to use OffScrub scripts to uninstall MS Office?

I created a separate directory for each version of Office:

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

Download and save each vbs file from GitHub to its own directory. You can use the following structure:

  • 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]

OffScrub_O16msi.vbs

In order for the Office removal script to work correctly on Windows x64 when running by the 32-bit Configuration Manager (SCCM) client, you should use the appropriate cscript.exe version. So, to run the OffScrub VBS on a 64-bit computer, you need to run cscript.exe from C:\Windows\SysWOW64.

You can achieve this using the 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)

Below are CLI commands to completely uninstall different versions of Microsoft Office:

Product VersionCommand
Office 2003Cscript.exe "%OFFICEREMOVE%\2003\OffScrub03.vbs” ALL /Quiet /NoCancel /Force /OSE
Command to uninstall Office via SCCM package: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2003\OffScrub03.vbs" ALL /Quiet /NoCancel /Force /OSE"
Office 2007Cscript.exe "%OFFICEREMOVE%\2007\OffScrub07.vbs” ALL /Quiet /NoCancel /Force /OSE
SCCM: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2007\OffScrub07.vbs" ALL /Quiet /NoCancel /Force /OSE"
Office 2010Cscript.exe "%OFFICEREMOVE%\2010\OffScrub10.vbs” ALL /Quiet /NoCancel /Force /OSE
SCCM: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2010\OffScrub10.vbs" ALL /Quiet /NoCancel /Force /OSE"
Office 2013Cscript.exe "%OFFICEREMOVE%\2013\OffScrub_O15msi.vbs” ALL /Quiet /NoCancel /Force /OSE
SCCM: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2013\OffScrub_O15msi.vbs" ALL /Quiet /NoCancel /Force /OSE"
Office 2016Cscript.exe "%OFFICEREMOVE%\2016\OffScrub_O16msi.vbs” ALL /Quiet /NoCancel /Force /OSE
SCCM: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "2016\OffScrub_O16msi.vbs" ALL /Quiet /NoCancel /Force /OSE"
Office 365 (C2R)Cscript.exe "%OFFICEREMOVE%\C2R\OffScrubc2r.vbs” ALL /Quiet /NoCancel /Force /OSE
SCCM: "%SystemRoot%\System32\cmd.exe" /C "NativeCScript.cmd //B //NoLogo "C2R\OffScrubc2r.vbs" ALL /Quiet /NoCancel /OSE"

removing office 2003 using offscrub vbs script

The Remove-PreviousOfficeInstalls Git project includes the Remove-PreviousOfficeInstalls.ps1 PowerShell script, which allows you to automatically detect the version of MS Office installed on the computer and call one of the Offscrub*.vbs removal scripts.

Uninstalling Microsoft.Office.Desktop App with PowerShell

Note that Windows 10/Windows 11 often comes preinstalled with Microsoft.Office.Desktop.Apps Microsoft Store UWP. You can remove this version of Office using PowerShell:

Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.Office.Desktop") {$_ | Remove-AppxProvisionedPackage -AllUsers}}

uninstall microsoft office desktop apps on windows 10 with powershell

Check out the article on how to remove built-in UWP/APPX apps on Windows.

You can also use the Get-Package and Uninstall-Package cmdlet to uninstall any application (win32, uwp, msi, etc.) in Windows:

Get-Package -Name "*Office*" | Uninstall-Package

11 comments
0
Facebook Twitter Google + Pinterest
previous post
Install and Configure SNMP Service on Windows Server and Windows 10/11
next post
How to Reset an Active Directory User Password with PowerShell and ADUC

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

11 comments

Lorenzo June 5, 2019 - 10:13 am

June 5th 2019. It worked fine for me on a residual Office 365 32 bit installation that did not let me install the 64 bit version. Thank you very much.

Reply
Phil August 11, 2020 - 10:05 am

Say for example, I want to remove Office 2013 using SCCM, where would I put that command line?
“%SystemRoot%\System32\cmd.exe” /C “NativeCScript.cmd //B //NoLogo “2013\OffScrub_O15msi.vbs” ALL /Quiet /NoCancel /Force /OSE”

Reply
Danny July 28, 2021 - 4:24 pm

I’d like to remove Office 2013, Office 365, and Office 2010 using SCCM. Can you send me instructions? (for ex, where do I save these OffScrub scripts and NaviteCScript.cmd?, how do I run thise command: “%SystemRoot%\System32\cmd.exe” /C “NativeCScript.cmd //B //NoLogo “2013\OffScrub_O15msi.vbs” ALL /Quiet /NoCancel /Force /OSE”?, do we only need to create a script to run or have to create a package with program on it?). Thank you very much for your helps.

Reply
admin July 29, 2021 - 9:07 am

Create a new package with all the required script files. Create a bat file with commands from the post and advertise it to clients.

Reply
Danny Pham August 2, 2021 - 11:57 pm

Do I have to use to NativeCScript.cmd? Where do I store this command? I test cscript.exe on local computer and it works fine. Just kind confuse when tried to implement it on SCCM. Can you send me a clear step by step instructions? Appreciate for your helps.

Reply
Danny August 3, 2021 - 10:08 pm

If all of our Configuration Manager clients are 64-bit, then we don’t need to use NativeCScript.cmd. How the command that we need to run on SCCM look like?

Reply
Prajyot November 16, 2021 - 2:15 pm

Hi,
When I run the offscrubc2r.vbs as an SCCM package, as a part of the removal it kills the explorer.exe. however at the end explorer.exe does not restart. I am guessing, it is starting but in the system context how do I start it in logged on users context?

Reply
serg July 18, 2022 - 1:07 pm

This appears to uninstall Office 2019 and earlier…
For remove Office 2021:
“C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe” scenario=install scenariosubtype=ARP sourcetype=None productstoremove=ProPlus2021Volume.16_en-us_x-none culture=en-us version.16=16.0

Reply
Serg September 21, 2022 - 4:21 am

When i run the package from software center or CcmCache i get a

01: Unidentified Argument Found

Scenario finished with exit code: [1].

In the program i use a uninstall command line:
SaRACmd.exe -S OfficeScrubScenario –AcceptEula -Officeversion All

The command line works when i use it to test the saracmd.exe and it uninstall all the office versions

BUT it does not work when i deploy the package OR test the command line from ccmcache.

Reply
Paul Rosenfeld November 11, 2022 - 7:53 pm

This was amazingly good and helped me take hold of a vexing issue in my O365 tenant. Thank you SO MUCH!

Reply
Satish C November 30, 2022 - 4:36 pm

Hi Paul, can provide me steps to uninstall old versions like MS Office 2013 with above scrips through SCCM.
Iam trying but no luck

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Signature Button Not Working in Outlook 2019/2016/365
  • Outlook Keeps Asking for Password on Windows
  • Configuring KMS License Server for Office 2021/2019/2016 Volume Activation
  • Send Outlook Emails Using Excel VBA Macro or PowerShell
  • How to Extend Office 2021/2019/2016 & Office 365 Trial Period
  • Installing an Open Source KMS Server (Vlmcsd) on Linux
  • Blank Sign-in Screen in Office 365 Apps (Outlook, Teams, etc.)
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top