Detta skript fungerar alltså för borttagning av samtliga appar, bibliotek, tillfälliga filer m.m.
1. Starta terminal
2. Leta dig fram till skriptet (lägg den i Nedladdat/Downloads t.ex.)
3. Navigera till platsen för skriptet i Terminal -fönstret.
(CD = ändra mapp osv, ls = Lista mapp innehåll)
4. Skriv skriptets namn
alt. sh /path/to/script.sh eller bash /path/to/script.sh
5. Låt skriptet köra.
6. Skriv lösenord för maccen när detta efterfrågas
4. Låt skriptet köra vidare.
--- SKRIPT ------------------------ Går även att ladda ner som fil i denna KB. (OBS! Ska exekveras från fil)
#!/bin/bash
################################################################################
# Microsoft Office for Mac Complete Uninstaller
################################################################################
#
# This script follows the official Microsoft support guidelines for completely
# uninstalling Microsoft Office for Mac (Microsoft 365, Office 2024, 2021, 2019)
#
# Official Microsoft Guide:
# https://support.microsoft.com/en-us/office/uninstall-office-for-mac-eefa1199-5b58-43af-8a3d-b73dc1a8cae3
#
# Updated: May 2025
# Version: 2.0
#
# DISCLAIMER: This software comes with absolutely NO WARRANTY.
# Use it at your own risk. Always backup important data before running.
#
################################################################################
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Function to check if running as admin/sudo
check_admin() {
if [[ $EUID -eq 0 ]]; then
print_error "This script should NOT be run as root/sudo."
print_error "It needs to access user directories and will prompt for admin password when needed."
exit 1
fi
# Check if user has admin privileges
if ! groups $(whoami) | grep -q admin; then
print_error "You must be an administrator to run this script."
exit 1
fi
}
# Function to safely remove files/directories
safe_remove() {
local path="$1"
local description="$2"
if [[ -e "$path" ]]; then
print_status "Removing $description: $path"
rm -rf "$path" 2>/dev/null || {
print_warning "Could not remove $path (may require admin password)"
sudo rm -rf "$path" 2>/dev/null || print_warning "Failed to remove $path"
}
fi
}
# Function to remove Office applications
remove_office_apps() {
print_status "Removing Microsoft Office applications..."
local apps=(
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft Word.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft AutoUpdate.app"
"/Applications/Microsoft Error Reporting.app"
)
for app in "${apps[@]}"; do
safe_remove "$app" "Office application"
done
}
# Function to remove user library containers
remove_user_containers() {
print_status "Removing user Library containers..."
local user_home="$HOME"
local containers_path="$user_home/Library/Containers"
# Containers to remove (following Microsoft's official list)
local containers=(
"Microsoft Error Reporting"
"Microsoft Excel"
"com.microsoft.netlib.shipassertprocess"
"com.microsoft.Office365ServiceV2"
"Microsoft Outlook"
"Microsoft PowerPoint"
"com.microsoft.RMS-XPCService"
"Microsoft Word"
"Microsoft OneNote"
"com.microsoft.errorreporting"
"com.microsoft.Excel"
"com.microsoft.Outlook"
"com.microsoft.Powerpoint"
"com.microsoft.Word"
"com.microsoft.onenote.mac"
)
for container in "${containers[@]}"; do
safe_remove "$containers_path/$container" "user container"
done
}
# Function to remove group containers
remove_group_containers() {
print_status "Removing user Library group containers..."
local user_home="$HOME"
local group_containers_path="$user_home/Library/Group Containers"
# Group containers to remove (following Microsoft's official list)
local group_containers=(
"UBF8T346G9.ms"
"UBF8T346G9.Office"
"UBF8T346G9.OfficeOsfWebHost"
)
for container in "${group_containers[@]}"; do
safe_remove "$group_containers_path/$container" "group container"
done
}
# Function to remove system-wide Office files
remove_system_files() {
print_status "Removing system-wide Office files..."
# System library files
local system_files=(
"/Library/Application Support/Microsoft"
"/Library/Fonts/Microsoft"
"/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist"
"/Library/LaunchDaemons/com.microsoft.office.licensingV2.helper.plist"
"/Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper"
"/Library/PrivilegedHelperTools/com.microsoft.office.licensingV2.helper"
)
for file in "${system_files[@]}"; do
if [[ -e "$file" ]]; then
print_status "Removing system file: $file"
sudo rm -rf "$file" 2>/dev/null || print_warning "Could not remove $file"
fi
done
# System preferences
local preferences=(
"/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*"
)
for pref in "${preferences[@]}"; do
if [[ -e "$pref" ]] || [[ "$pref" == *"*" ]]; then
print_status "Removing preference: $pref"
sudo rm -rf $pref 2>/dev/null || print_warning "Could not remove $pref"
fi
done
# Receipts
print_status "Removing installation receipts..."
sudo rm -rf /Library/Receipts/Office* 2>/dev/null || true
sudo rm -rf /Library/Receipts/*Office* 2>/dev/null || true
}
# Function to forget packages using pkgutil
forget_packages() {
print_status "Making system forget Office packages..."
local packages=(
"com.microsoft.package.Fonts"
"com.microsoft.package.Microsoft_AutoUpdate.app"
"com.microsoft.package.Microsoft_Excel.app"
"com.microsoft.package.Microsoft_OneNote.app"
"com.microsoft.package.Microsoft_Outlook.app"
"com.microsoft.package.Microsoft_PowerPoint.app"
"com.microsoft.package.Microsoft_Word.app"
"com.microsoft.package.Proofing_Tools"
"com.microsoft.package.licensing"
"com.microsoft.package.Frameworks"
"com.microsoft.pkg.licensing"
)
for package in "${packages[@]}"; do
if pkgutil --pkgs | grep -q "^$package$"; then
print_status "Forgetting package: $package"
sudo pkgutil --forget "$package" 2>/dev/null || print_warning "Could not forget package $package"
fi
done
}
# Function to check and remove from Dock
check_dock() {
print_status "Checking Dock for Office applications..."
print_warning "If you have Office apps in your Dock, please manually remove them:"
print_warning "Right-click the app in Dock → Options → Remove from Dock"
}
# Main function
main() {
echo -e "${BLUE}"
echo "################################################################################"
echo "# Microsoft Office for Mac Complete Uninstaller #"
echo "################################################################################"
echo -e "${NC}"
echo
echo "This script will completely remove Microsoft Office for Mac following"
echo "the official Microsoft support guidelines."
echo
echo "Supported versions:"
echo "- Microsoft 365 for Mac"
echo "- Office 2024 for Mac"
echo "- Office 2021 for Mac"
echo "- Office 2019 for Mac"
echo "- Office 2016 for Mac"
echo
print_warning "⚠️ IMPORTANT WARNINGS:"
print_warning "• All Outlook data will be permanently removed"
print_warning "• Make sure to backup any important data before proceeding"
print_warning "• This action cannot be undone"
echo
read -p "Do you want to continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_status "Uninstallation cancelled."
exit 0
fi
echo
print_warning "Last chance to abort! Press Ctrl+C within 5 seconds to cancel..."
sleep 5
echo
print_status "Starting Office uninstallation process..."
# Check admin privileges
check_admin
# Step 1: Remove Office applications
remove_office_apps
# Step 2: Remove user library containers
remove_user_containers
# Step 3: Remove group containers
remove_group_containers
# Step 4: Remove system files (requires admin password)
print_status "Removing system files (admin password may be required)..."
remove_system_files
# Step 5: Forget packages
forget_packages
# Step 6: Check Dock
check_dock
echo
print_success "✅ Microsoft Office uninstallation completed successfully!"
echo
print_status "Recommended next steps:"
echo " 1. Remove any Office apps from your Dock manually"
echo " 2. Restart your Mac to complete the uninstallation"
echo " 3. Empty your Trash"
echo
print_warning "Note: You may need to reinstall Microsoft Silverlight if other"
print_warning " applications require it."
echo
read -p "Would you like to restart your Mac now? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
print_status "Restarting in 10 seconds... Press Ctrl+C to cancel."
sleep 10
sudo shutdown -r now
else
print_status "Please remember to restart your Mac manually to complete the uninstallation."
fi
}
# Run main function
main "$@"------------------------------
Source: https://github.com/qsor27/office-mac-uninstaller/blob/main/uninstall-office-mac.sh