-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstallMicrosoftoffice2016.sh
125 lines (110 loc) · 4.14 KB
/
uninstallMicrosoftoffice2016.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# This program will uninstall Microsoft Office 2016
#################
### Variables ###
#################
# Items at the system level to be removed
systemItems=(
/Applications/Microsoft\ Excel.app
/Applications/Microsoft\ OneNote.app
/Applications/Microsoft\ Outlook.app
/Applications/Microsoft\ PowerPoint.app
/Applications/Microsoft\ Word.app
/Applications/Microsoft\ Lync.app
/Library/Application\ Support/Microsoft/MAU2.0
/Library/Fonts/Microsoft
/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
/Library/LaunchDaemons/com.microsoft.office.licensingV2.helper.plist
/Library/Preferences/com.microsoft.Excel.plist
/Library/Preferences/com.microsoft.office.plist
/Library/Preferences/com.microsoft.office.setupassistant.plist
/Library/Preferences/com.microsoft.outlook.databasedaemon.plist
/Library/Preferences/com.microsoft.outlook.office_reminders.plist
/Library/Preferences/com.microsoft.Outlook.plist
/Library/Preferences/com.microsoft.PowerPoint.plist
/Library/Preferences/com.microsoft.Word.plist
/Library/Preferences/com.microsoft.office.licensingV2.plist
/Library/Preferences/com.microsoft.autoupdate2.plist
/Library/Preferences/ByHost/com.microsoft
/Library/Receipts/Office2016_*
/Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper
/Library/PrivilegedHelperTools/com.microsoft.office.licensingV2.helper
/Library/Application\ Support/JAMF/Receipts/Office* #replace with the receipt for your Office installer via Jamf
/Library/Application\ Support/JAMF/Receipts/Microsoft* #replace with your receipt for your Office/serializer via Jamf
/Library/Internet\ Plug-Ins/MeetingJoinPlugin.plugin
)
# Items at the user level to be removed
userItems=(
Library/Containers/com.microsoft.errorreporting
Library/Containers/com.microsoft.Excel
Library/Containers/com.microsoft.netlib.shipassertprocess
Library/Containers/com.microsoft.Office365ServiceV2
Library/Containers/com.microsoft.Outlook
Library/Containers/com.microsoft.Powerpoint
Library/Containers/com.microsoft.RMS-XPCService
Library/Containers/com.microsoft.Word
Library/Containers/com.microsoft.onenote.mac
Library/Group\ ContainersUBF8T346G9.ms/
Library/Group\ ContainersUBF8T346G9.Office/
Library/Group\ ContainersUBF8T346G9.OfficeOsfWebHost/
Library/Application\ Scripts/com.microsoft.Office365ServiceV2
Library/Preferences/com.microsoft.Lync.plist
Library/Preferences/ByHost/MicrosoftLyncRegistrationDB.*.plist
Library/Logs/Microsoft-Lync*.log*
Documents/Microsoft\ User\ Data/Microsoft\ Lync\ Data/
Documents/Microsoft\ User\ Data/Microsoft\ Lync\ History/
Library/Keychains/OC_*
)
#################
### Functions ###
#################
function deleteItems()
{
declare -a toDelete=("${!1}")
for item in "${toDelete[@]}"
do
if [[ ! -z "${2}" ]]
then
item=("${2}""${item}")
fi
echo "Looking for $item"
if [ -e "${item}" ]
then
echo "MS Office Uninstall: Removing $item"
rm -rf "${item}"
fi
done
}
####################
### Main Program ###
####################
# Kill the apps, if they are running
echo "MS Office Uninstall: Closing Office-related apps."
killall "Microsoft Excel"
killall "Microsoft Word"
killall "Microsoft PowerPoint"
killall "Microsoft Outlook"
killall "Microsoft OneNote"
killall "Microsoft Auto-Update"
killall "Microsoft Lync"
killall "Microsoft Update Assistant"
# Delete system level items
deleteItems systemItems[@]
# Delete user level items
for dirs in /Users/*/
do
deleteItems userItems[@] "${dirs}"
done
# Delete package receipts
echo "MS Office Uninstall: Removing package receipts."
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.Microsoft_Lync.app
pkgutil --forget com.microsoft.package.Proofing_Tools
pkgutil --forget com.microsoft.package.licensing
exit 0