Script to Remove ALL Office Programs prior to deploying Office 2016 from a network location!

In this article, I will show you how to setup a script to Remove ALL Office Programs from a user’s PC, prior to deploying Office 2016.

Office 2016 will not install if you have fragments of older Office programs on the machine.

There are two scripts that will be covered in two separate articles, the next Article will show you How to Deploy Office 2016 using a script, from a network location.

I’ve tested this process on a live domain, and have significantly reduced the time it takes to Remove previous Office versions and Deploy Office 2016 Pro Plus w/Visio.

 

Step 1 – Download Office Removal Tool from Microsoft

This tool can be found here: Office Removal Tool. The page states it removes Office 2016/2013, but it does in fact remove all previous versions including Office 2007 and Office 2010.

Filename: o15-ctrremove.diagcab 

Step 2 – Save this file to a Network Share

Save this file in a network location of the server of your choice. This folder on your network needs to be shared to everyone, so that users or your help desk staff can run the scripts from a user’s pc. I named my Network Share “OFFICE2016”, as I use this location for BOTH the UNINSTALL script and the INSTALL Office 2016 scripts.

Note: If you are attempting to uninstall your entire organization in one day, you could use the script below and deploy it using Group Policy. I have over 1000 remote users, so I could not go this route.

Step 3 – Modify this Uninstall Script to work in your environment

I placed this file in a share named “OFFICE2016” along with the files from the next article.

@echo off

setlocal

::Store working directory to return after finished
set WORKDIR=%CD%

::Map and switch to a network drive and give it unmapped drive letter
pushd \\YOURSERVER_FQDN_or_IP\OFFICE2016\

::Store the name of the network drive so it can be unmapped when finished
Set NETDRIVE=%CD%
set NETDRIVE=%NETDRIVE:\=%

::Change back to the original directory
cd /d %WORKDIR%

::Run commands with the network drive mapped
%NETDRIVE%\o15-ctrremove.diagcab

::Uncomment this to catch errors from the executable
::if %errorlevel% GTR o exit %errorlevel%

::Unmap the network drive
net use %NETDRIVE% /delete /y

::Reboot the machine once Uninstall GUI Completes
pushd c:\windows\system32
shutdown -r -f -t 0

endlocal

Save the script as a BAT file, I named mine “NETWORK-REMOVE-OFFICE-ALL.BAT

The process of this script:

When you run this script, it will create a temporary network share on the pc. Open the MS Uninstall Microsoft Office GUI. Remove the temporary network share when finished. When your user or help desk follows the prompts, once the GUI has been closed, the computer will reboot.

This will allow you to move to the next script Deploy Office 2016 using a script, from a network share!

Step 4 – Run the script on a user’s PC!

Navigate to your OFFICE2016 network share and run the “Network-Remove-OFFICE-ALL.bat“, as an administrator.

uninstalloffice

Again: Once you have navigated this GUI, by clicking the NEXT button, the GUI finishes, and the user’s machine will AUTOMATICALLY reboot!

My Real Time Test using this method are below:

Download the o15-ctrremove.diagcab  file on each computer then run = 35 minutes

Uninstall ALL versions MS Office using the above Script averages:  4 minutes!

Download the Office 2016 installer executable, and run = 45 minutes

Install Office 2016 using the next script averages: 9 Minutes!

 

Errors that you may encounter:

Error #1

This error was from a Window 7 Pro machine, that had OS issues and possibly Malware.error4

Since I am removing Windows 7 from my environment, the machine was replaced.

Error #2

BELOW is an error that you may run into, In a very special case:

The error is from running a network share from a Laptop (as a mobile file server if you will). This was setup for my help desk to use at a location, rather than from my corporate network. If you receive this error, you can ignore it, as the script will continue to run.

20170224_115257

Again, this error was from the network share being shared from a laptop, not an actual server network share. 

Below are the files in my Network Share “OFFICE2016”.

This includes BOTH the UNINSTALLER and Office 2016 Pro Installer, and both scripts.

networklocation

Advertisements