Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Silent Uninstall of Office 2016
# Completely uninstall Office 2016, as per:
# and
import glob
import os
import shutil
import subprocess
def main():
apps = ("Microsoft Excel", "Microsoft OneNote",
"Microsoft Outlook", "Microsoft PowerPoint",
"Microsoft Word")
# Step 1: Remove Office 2016 for Mac applications.
for app in apps:
shutil.rmtree(os.path.join("/Applications", app + ".app"),
# Step 2: Remove Supporting Files.
# rm Licensing, stop jobs.
job = ("/Library/LaunchDaemons/"
"")["launchctl", "unload", job])
license_files = (
for license_file in license_files:
except OSError:
print "File '{}' has already been removed.".format(license_file)
# rm Containers
container_names = ("errorreporting", "Excel", "netlib.shipassertprocess",
"Office365ServiceV2", "Outlook", "Powerpoint",
"RMS-XPCService", "Word", "onenote.mac")
containers = ("{}".format(name) for name in container_names)
for container in containers:
present_containers = glob.glob(
os.path.join("/Users/*/Library/Containers/", container))
for present_container in present_containers:
# rm Group Containers
# Please note: This is where local-only data lives, so back it up
# if you care about it!
group_containers = ("", "UBF8T346G9.Office",
for container in group_containers:
present_containers = glob.glob(
os.path.join("/Users/*/Library/Group Containers/", container))
for present_container in present_containers:
# Step 3: Remove keychain entries.
# During testing, I had three seemingly identical items with "value"/"gena"
# string "MSOpenTech.ADAL.1". Deleting only affects one at a time, so
# iterate.
exit_code = 0
while exit_code == 0:
exit_code =
["security", "delete-generic-password", "-G", "MSOpenTech.ADAL.1"])
["security", "delete-generic-password", "-l",
"Microsoft Office Identities Cache 2"])
["security", "delete-generic-password", "-l",
"Microsoft Office Identities Settings 2"])
# Step 4: Remove Office 2016 for Mac icons from the dock.
dockutil_available = False
try:["dockutil", "--version"])
dockutil_available = True
except OSError:
if dockutil_available:
for app in apps:["dockutil", "--remove", app, "--allhomes"])
print "dockutil not present: skipping dock item removal."
# Step 5: Restart.
# No thanks.
# Help Munki by removing receipts.
receipts = (
for receipt in receipts:["pkgutil", "--forget", receipt])
if __name__ == "__main__":

This comment has been minimized.

Copy link
Owner Author

@sheagcraig sheagcraig commented Sep 26, 2016

This script can be Munki makepkginfo-ed into a Self-Service uninstaller for users hoping to troubleshoot issues with their office install. Afterwards, Office 2016 applied within a managed_install list will be available for reinstallation.

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