Mac Office 2011 - Uninstall Script

lee_smith
Contributor

Hey Everyone!

We will be moving to Microsoft Office 2016 for Mac this summer. In preparation, I would like to remove Office for Mac 2011.

  • How are you all uninstalling Office?
    -- Note: We did not deploy office using Casper. So, I am not able to create an uninstaller.

  • Does anyone have a script that will silently uninstall Office?
    -- No user prompts, etc.

Thank you all in advance.

22 REPLIES 22

stevewood
Honored Contributor II
Honored Contributor II

@lee.smith you'll want to test this but....

Remove Office 2011

mm2270
Legendary Contributor III

I've used @talkingmoose's script as referenced above a number of times when doing Office 2011 update testing in house. It was originally written a while ago, but still does the job well and is the most thorough way to remove Office that I've seen.

lee_smith
Contributor

thank you both @stevewood @mm2270

Thanks!

lee_smith
Contributor

Here is what I have performed:
- Copied Script into Casper
- Created Policy
-- scoped to two test machines
- Script ran successfully according to Casper
- Logged into computer and still found SOME remnants of Office 2011 - I didn't check all the other places but found theses.
-- /Users/Administrator/Library/Preferences
-- /Library/Preferences/
-- Dock Icons

How can we remove the dock icons?

mm2270
Legendary Contributor III

dockutil

Edit: though actually you can use the built in Dock icon functionality in Casper for this. for ex: Add all the Microsoft Office icons you might need to remove into Casper Admin.
In your Office 2011 removal policy, in the Dock Items payload section, actually click the "Add" button next to each app name. For each one you add, change the pop up menu from "Add to Beginning of Dock" to "Remove from Dock" When the policy runs, it will try to remove that icon from the Dock.

Try that and see how it works.

jhbush
Valued Contributor II

@lee.smith

/usr/local/bin/dockutil --remove 'Microsoft Word' --allhomes
/usr/local/bin/dockutil --remove 'Microsoft Outlook' --allhomes
/usr/local/bin/dockutil --remove 'Microsoft PowerPoint' --allhomes
/usr/local/bin/dockutil --remove 'Microsoft Excel' --allhomes

farverk
New Contributor III

Here is what I've been working on. It works 100% but by no means am I a script expert.

#!/bin/sh

osascript -e 'tell application "Microsoft Database Daemon" to quit'
osascript -e 'tell application "Microsoft AU Daemon" to quit'
osascript -e 'tell application "Office365Service" to quit'

#Closes all Office applications
osascript -e 'tell application "Microsoft Excel.app" to quit without saving'
osascript -e 'tell application "Microsoft PowerPoint.app" to quit without saving'
osascript -e 'tell application "Microsoft Word.app" to quit without saving'

#Have to kill Outlook process to close any open drafted emails or it will fail
killall -kill "Microsoft Outlook"

rm -R '/Applications/Microsoft Communicator.app/'
rm -R '/Applications/Microsoft Messenger.app/'
rm -Rd '/Applications/Microsoft Office 2011/'
#rm -R '/Applications/Remote Desktop Connection.app/'
rm -R '/Library/Application Support/Microsoft/MAU2.0'
rm -R '/Library/Application Support/Microsoft/MERP2.0'
rm -R /Library/Automator/*Excel*
rm -R /Library/Automator/*Office*
rm -R /Library/Automator/*Outlook*
rm -R /Library/Automator/*PowerPoint*
rm -R /Library/Automator/*Word*
rm -R /Library/Automator/*Workbook*
rm -R '/Library/Automator/Get Parent Presentations of Slides.action'
rm -R '/Library/Automator/Set Document Settings.action'
rm -R /Library/Fonts/Microsoft/
rm -R /Library/Internet Plug-Ins/SharePoint*
rm -R /Library/LaunchDaemons/com.microsoft.*
rm -R '/Library/Preferences/com.microsoft.office.licensing.plist'
rm -R /Library/PrivilegedHelperTools/com.microsoft.*

OFFICERECEIPTS=$(pkgutil --pkgs=com.microsoft.office.*)

for ARECEIPT in $OFFICERECEIPTS
do
            pkgutil --forget $ARECEIPT
    done

exit 0

Will definitely be adding the removal of dock icons per @jhbush1973 script.

robby_c137
New Contributor III

Thanks @farvek

I made sure (after learning the hard way) to omit removing Microsoft Update since we install 2016 before removing 2011.

rm -R '/Library/Application Support/Microsoft/MAU2.0'

KyleEricson
Valued Contributor II

You can try this.

do shell script "killall 'Microsoft Outlook' some-arbitrary-command || true"

do shell script "killall 'Microsoft Excel' some-arbitrary-command || true"

do shell script "killall 'Microsoft Word' some-arbitrary-command || true"

do shell script "killall 'Microsoft PowerPoint' some-arbitrary-command || true"

do shell script "killall 'Microsoft Lync' some-arbitrary-command || true"

do shell script "sudo rm -rf '/Applications/Microsoft Office 2011'" user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -rf '/Applications/Microsoft Lync.app'" user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r '/Applications/Microsoft Communicator.app' " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r '/Applications/Remote Desktop Connection.app' " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r /Library/Fonts/Microsoft/ " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r /Library/Preferences/Microsoft " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r /Library/PrivilegedHelperTools/microsoft" user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "rm -r ~/Library/Preferences/microsoft "

do shell script "sudo rm -r '/Library/Internet Plug-Ins/SharePointBrowserPlugin.plugin' " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

do shell script "sudo rm -r '/Library/Internet Plug-Ins/SharePointWebKitPlugin.webplugin' " user name "Administrator" password "enteryourpasswordhere" with administrator privileges

tell application "System Events" delete folder "~/Library/Application Support/Microsoft/Office"
end tell

display dialog "Office Has been unistalled" with icon stop giving up after 2

Read My Blog: https://www.ericsontech.com

marc_grubb
New Contributor III

Microsoft details ALL the Office 2011 files & locations in this article: Troubleshoot Office 2011 for Mac issues by completely uninstalling before you reinstall.

I added to the script above, which should be credited to OfficeForMacHelp.com. My script does not remove Dock items as others suggest, but IS more thorough, and also removes user preferences and files for the current user. In addition, the Microsoft User Data folder is renamed Microsoft User Data Archive (& preserved). I created a Self Service policy so that that my colleagues can run the uninstaller themselves.

It looks like the script formatting is broken based on the color-coding. The script can be found on my GitHub repo

#!/bin/sh
# Quits background processes/daemons
osascript -e 'tell application "Microsoft Database Daemon" to quit'
osascript -e 'tell application "Microsoft AU Daemon" to quit'
osascript -e 'tell application "Office365Service" to quit'

# Kill Outlook to close any open drafted emails or it will fail
killall -kill "Microsoft Outlook"

# Close other Office Apps
osascript -e 'tell application "Remote Desktop Connection" to quit' 
osascript -e 'tell application "Microsoft Document Connection" to quit'
osascript -e 'tell application "Microsoft Messenger" to quit'
osascript -e 'tell application "Microsoft Communicator" to quit'
osascript -e 'tell application "Microsoft Excel" to quit'
osascript -e 'tell application "Microsoft PowerPoint" to quit'
osascript -e 'tell application "Microsoft Word" to quit'
osascript -e 'tell application "Microsoft Office Reminders" to quit'

# Pull current logged in user into 'user' variable.
user=`ls -l /dev/console | cut -d " " -f 4`

# Remove Apps, preferences, fonts, files, licensing, receipts, etc.
rm -R /Library/LaunchDaemons/com.microsoft.*
rm -R '/Library/Preferences/com.microsoft.office.licensing.plist'
rm -R /Library/PrivilegedHelperTools/com.microsoft.*
rm -R '/Applications/Microsoft Communicator.app/'
rm -R '/Applications/Microsoft Messenger.app/'
rm -R '/Applications/Microsoft Office 2011/'
rm -R '/Applications/Remote Desktop Connection.app/'
rm -Rf 'Applications/Microsoft Office 2011'
rm -R '/Library/Application Support/Microsoft/MAU2.0'
rm -R '/Library/Application Support/Microsoft/MERP2.0'
rm -R '/Library/Application Support/Microsoft/Office'
rm -R /Library/Automator/*Excel*
rm -R /Library/Automator/*Office*
rm -R /Library/Automator/*Outlook*
rm -R /Library/Automator/*PowerPoint*
rm -R /Library/Automator/*Word*
rm -R /Library/Automator/*Workbook*
rm -R '/Library/Automator/Get Parent Presentations of Slides.action'
rm -R '/Library/Automator/Set Document Settings.action'
rm -Rf /Library/Fonts/Microsoft/
rm -R /Library/Internet Plug-Ins/SharePoint*
rm -R /Library/Preferences/com.microsoft*
rm -R '/Library/Preferences/Microsoft/'

# Rename Microsoft User Data as Rename Microsoft User Data Archive
mv /Users/$user/Documents/Microsoft User Data /Users/$user/Documents/Microsoft User Data Archive

# Delete User preferences
rm /Users/$user/Library/Preferences/com.microsoft.Excel.plist
rm /Users/$user/Library/Preferences/com.microsoft.office*.plist
rm /Users/$user/Library/Preferences/com.microsoft.Excel.plist
rm /Users/$user/Library/Preferences/com.microsoft.outlook*.plist
rm /Users/$user/Library/Preferences/com.microsoft.Outlook*.plist
rm /Users/$user/Library/Preferences/com.microsoft.PowerPoint.plist
rm /Users/$user/Library/Preferences/com.microsoft.Word.plist
rm /Users/$user/Library/Preferences/ByHost/com.microsoft*

# Delete User Application Support
rm -Rf /Users/$user/Library/Application Support/Microsoft/Office

OFFICERECEIPTS=$(pkgutil --pkgs=com.microsoft.office.*)

for ARECEIPT in $OFFICERECEIPTS
do
            pkgutil --forget $ARECEIPT
    done

exit 0

mbezzo
Contributor III

Thanks @marc_grubb!

Anybody know of a tricky method to distinguish between killing Outlook 2016 and Outlook 2011? It's not a HUGE deal, but killall -kill "Microsoft Outlook" is gonna kill both. Is this possible? Looks like they both have the same exact process name...

Thanks,
Matt

mbezzo
Contributor III

and... one more thing :)

With the exception of MAU, this doesn't delete anything relating to Office 2016 correct? Due to our situation, we're going to be removing 2011 after 2016 has been installed.

mbezzo
Contributor III

I've been doing some testing with this when both 2016 and 2011 are installed. If I comment out the MAU deletion line, MAU is still there, but office 2016 apps no longer have the "Check for Updates" option in the Help menu. What controls that?? I assume whatever it is is also get getting deleted....

Thanks,
Matt

mm2270
Legendary Contributor III

@mbezzo Re:

Anybody know of a tricky method to distinguish between killing Outlook 2016 and Outlook 2011? It's not a HUGE deal, but killall -kill "Microsoft Outlook" is gonna kill both. Is this possible? Looks like they both have the same exact process name...

You can try the following script. It relies on the fact that Office 2011 apps should (hopefully) only be running from the full /Applications/Microsoft Office 2011/Microsoft <app_name> path, as opposed to Office 2016 apps that get installed into, and run from, the main /Applications/ folder.

#!/bin/bash

O2016Apps=("Microsoft Outlook.app"
"Microsoft Word.app"
"Microsoft Excel.app"
"Microsoft PowerPoint.app")

for app in "${O2016Apps[@]}"; do
    process=$(ps axwww | grep "[/]Applications/Microsoft Office 2011/${app}" | awk '{print $1}')
    if [[ "$process" != "" ]]; then
        echo "${app} is running. Killing process ${process}..."
        kill -9 $process
    fi
done

BTW, I did test this. I have both Office 2011 and Office 2016 installed on my Mac and I had 2 2016 apps running (Outlook and Word) and opened the 2011 version of PowerPoint and it correctly saw that PowerPoint was open and needed to be quit. It left the 2016 apps alone.

mbezzo
Contributor III

@mm2270 Sweet, thank you. Will definitely give that a shot!

kbach
New Contributor

Has anyone seen by uninstalling Office 2011 with Office 2016 installed that users are being prompted to Activate Office 2016 for Mac?

After running the script(s) above, each targeted Mac, the user is being prompted to activate. Only after reinstalling Office 2016 for Mac, does the user not get prompted.

jhbush
Valued Contributor II

@kbach I'm guessing that's due to /Library/Preferences/com.microsoft* being removed. The license file would be removed if you ran that.

kbach
New Contributor

@jhbush1973

In this case, my script is removing the licensing plist '/Library/Preferences/com.microsoft.office.licensing.plist' - not the system level /Library/Preferences/com.microsoft I'm not deleting in that path.

This explains the user experience for having to activate. Of course, I'll test and confirm but that makes sense.

Thanks!

bbot
Contributor

@marc_grubb If our machines already have Office 2016 installed and we run your script to remove Office 2011. Will anything be affected?

I know Office 2016 app is self contained, just wondering if 2011 and 2016 share any plist files that may affect the user experience if we run your script.

DanJ_LRSFC
Contributor III

I've been trying to use Microsoft's official script for removing Office 2011, but although I managed to adapt it enough to get it working with Casper, Casper Remote still picks up an error condition from the script even though the script succeeds and has an exit code of 0.

The official Microsoft script seems to do several things that are not covered by the scripts in this thread which is why I wanted to use it as a starting point.

Does anyone have any suggestions?

mpermann
Valued Contributor II

@DanJ_LRSFC I've created an installer package using Composer that puts the script and the dockutil binary in /private/tmp/Office2011Removal then I have a post install script that runs the actual removal script. This has worked well for me. See the attached image for how I have it setup.
1f06f88f7b844e8da77aba0f7f2c6276

applejunkie
New Contributor

I hate to resurrect this thread but it's the best I've found yet on removing Microsoft Office 2011 with Casper. Within our environment, we might have user created content that we can't chance being deleted by these scripts. I'm only a beginner but can someone help me with simple code I can add to @marc_grubb's git hub code that would search and relocate distinct file extensions (.olm, .xltx, .dotx, .potx, etc) to an organized folder on the users desktop prior to software removal?

Maybe "MS Office 2011 Preserved Items" with subfolders that that separates these files? Folder structure could be something like:
8342d61f384d498fbf5cc54a12a17015

@marc_grubb had a great start in his github repository that I'd like to add these additional features to if possible.

For our purposes, we also already have Microsoft 2016 installed so I would not want to delete MAU2.0 as mentioned by @true[robby]. But I could simply comment out those lines (32 & 33) to retain.

Would it be line 25 that I should also comment out to retain licensing information as mentioned by @kbach?