Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uninstall Office 2016 from OS X completely
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "
ROOT PRIVILEDGES NEEDED!
You have to run this script as root.
Aborting...
"
exit 1
else
echo -e "
###################################
Office 2016 for Mac uninstaller
###################################
Unofficial unistaller
Brought to you by Frank Pira
(fpira.com)
This software comes with absolutely
NO WARRANTY
Use it at your own risk.
"
sleep 4
echo -e "
------------- WARNING -------------
Your Outlook data will be wiped.
Press CTRL+C in 5 seconds to ABORT
or just sit back and relax!
-----------------------------------
"
sleep 6
# commands out of the official guide from microsoft
# source https://support.office.com/en-us/article/Uninstall-Office-2016-for-Mac-eefa1199-5b58-43af-8a3d-b73dc1a8cae3
echo " Removing Office 2016 apps..."
rm -rf "/Applications/Microsoft Excel.app"
rm -rf "/Applications/Microsoft OneNote.app"
rm -rf "/Applications/Microsoft Outlook.app"
rm -rf "/Applications/Microsoft PowerPoint.app"
rm -rf "/Applications/Microsoft Word.app"
echo " Cleaning ~/Library..."
rm /Users/$(whoami)/Library/Containers/com.microsoft.errorreporting
rm /Users/$(whoami)/Library/Containers/com.microsoft.Excel
rm /Users/$(whoami)/Library/Containers/com.microsoft.netlib.shipassertprocess
rm /Users/$(whoami)/Library/Containers/com.microsoft.Office365ServiceV2
rm /Users/$(whoami)/Library/Containers/com.microsoft.Outlook
rm /Users/$(whoami)/Library/Containers/com.microsoft.Powerpoint
rm /Users/$(whoami)/Library/Containers/com.microsoft.RMS-XPCService
rm /Users/$(whoami)/Library/Containers/com.microsoft.Word
rm /Users/$(whoami)/Library/Containers/com.microsoft.onenote.mac
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.ms"
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.Office"
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.OfficeOsfWebHost"
# further cleaning
echo " Cleaning system folders..."
rm -rf "/Library/Application Support/Microsoft/MAU2.0"
rm -rf "/Library/Fonts/Microsoft"
rm /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
rm /Library/LaunchDaemons/com.microsoft.office.licensingV2.helper.plist
rm /Library/Preferences/com.microsoft.Excel.plist
rm /Library/Preferences/com.microsoft.office.plist
rm /Library/Preferences/com.microsoft.office.setupassistant.plist
rm /Library/Preferences/com.microsoft.outlook.databasedaemon.plist
rm /Library/Preferences/com.microsoft.outlook.office_reminders.plist
rm /Library/Preferences/com.microsoft.Outlook.plist
rm /Library/Preferences/com.microsoft.PowerPoint.plist
rm /Library/Preferences/com.microsoft.Word.plist
rm /Library/Preferences/com.microsoft.office.licensingV2.plist
rm /Library/Preferences/com.microsoft.autoupdate2.plist
rm -rf /Library/Preferences/ByHost/com.microsoft
rm -rf /Library/Receipts/Office2016_*
rm /Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper
rm /Library/PrivilegedHelperTools/com.microsoft.office.licensingV2.helper
echo " Making your Mac forget about Office 2016..."
pkgutil --forget com.microsoft.package.Fonts
pkgutil --forget com.microsoft.package.Microsoft_AutoUpdate.app
pkgutil --forget com.microsoft.package.Microsoft_Excel.app
pkgutil --forget com.microsoft.package.Microsoft_OneNote.app
pkgutil --forget com.microsoft.package.Microsoft_Outlook.app
pkgutil --forget com.microsoft.package.Microsoft_PowerPoint.app
pkgutil --forget com.microsoft.package.Microsoft_Word.app
pkgutil --forget com.microsoft.package.Proofing_Tools
pkgutil --forget com.microsoft.package.licensing
echo -e "
All done!
You may need to reinstall Microsoft Silverlight.
You can now remove icons from Dock (if any!).
"
fi
@guojiubo

This comment has been minimized.

Copy link

guojiubo commented Sep 9, 2016

Nice work!
However, I found an issue when I use this script to uninstall my Office for Mac 2016 (version 15.20), it leaves two packages named 'com.microsoft.package.Frameworks' and 'com.microsoft.pkg.licensing' behind, it seams like Microsoft has made some change there, maybe we should also use pkgutil to forget those two, right?

@charliwest

This comment has been minimized.

Copy link

charliwest commented Nov 18, 2016

Do you have or know of a 2008 version?

@whalesingswee

This comment has been minimized.

Copy link

whalesingswee commented Oct 21, 2017

Hi Pira, when I run this with sudo, it seems $(whoami) becomes root and it didn't clean up the folders, as well as just simply using rm seems like it's not going to remove the folder without forcing it.

@rhortal

This comment has been minimized.

Copy link

rhortal commented Oct 24, 2017

Are the lines on Group Containers such as:
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.ms"
missing a trailing slash after Containers?

@stonerl

This comment has been minimized.

Copy link

stonerl commented Dec 12, 2017

@rhortal Yes they do.

@roma0803

This comment has been minimized.

Copy link

roma0803 commented Apr 25, 2018

Nice one, thanks a lot for this script. I had a big issue with OneNote. Unable to open it, even after an uninstall an clean install. Different solutions on The Net didn't fix it. I ran this script, reinstalled Office and no issue at all anymore. Saved my work and saved the day!

@mcoam

This comment has been minimized.

Copy link

mcoam commented Jun 9, 2018

Great!

@fuzheng1998

This comment has been minimized.

Copy link

fuzheng1998 commented Sep 29, 2018

I ran it under sudo privilege, but still can't clear sys files, showing no such directory or files

@radusuciu

This comment has been minimized.

Copy link

radusuciu commented Nov 27, 2018

Perhaps this could be fleshed out to avoid issues with sudo as done in the Remove2011 project: https://github.com/pbowden-msft/Remove2011/blob/master/Remove2011#L238

function RemoveUserComponent {
	FUNCPATH="$1"
	FUNCTEXT="$2"
	LogMessage "In function 'RemoveUserComponent with arguments $FUNCPATH and $FUNCTEXT'"
	for u in `ls /Users`; do
		FULLPATH="/Users/$u/$FUNCPATH"
		$(sudo rm -r -f $FULLPATH)
	done
}
@radusuciu

This comment has been minimized.

Copy link

radusuciu commented Nov 27, 2018

Also, this fork seems like it solves a lot of the issues:

https://gist.github.com/pythoninthegrass/9e4d3ef0f2036746467add17c76b4c15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.