Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Last active March 21, 2024 14:12
  • Star 66 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pirafrank/18d62c062e2806c1d183 to your computer and use it in GitHub Desktop.
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
@radusuciu
Copy link

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

@pythoninthegrass
Copy link

pythoninthegrass commented Jan 3, 2020

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

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

Hey @radusuciu,

WAAAAY late to the party. Needed my / @pirafrank's script again for work and went down the rabbit hole of refactoring the last version I posted. Now pkgutil actually forgets PLISTs (fixed incorrect operator), array that pkgutil uses is now dynamic instead of a fixed list, /Applications are now correctly removed due to quirky .app extension behavior (directories vs. files), and lastly, all echo[es] calling array items have been replaced with printf to capture all the output instead of the first line.

Hope you find that useful. Pull requests welcome!

@radusuciu
Copy link

Thanks for the notes @pythoninthegrass!

To be honest, I forget why I was even looking at this in the first place 🎈

@pythoninthegrass
Copy link

You're welcome, @radusuciu! Stealing that red balloon emoji -- gonna work its way into Slack convos somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment