How to Completely Remove/Delete Apps from MacOS

发布于:2025-08-17 ⋅ 阅读:(14) ⋅ 点赞:(0)
(venv) egonever@egonevers-MacBook-Air temp % ls /Applications | grep -i adrive

aDrive.app

I need to completely uninstall and remove aDrive.app

Let's fully uninstall aDrive.app from your Mac. Here's a step-by-step guide to ensure a clean removal:

🧼 Step 1: Remove the App Bundle

bash

sudo rm -rf /Applications/aDrive.app

This deletes the main application from your system.

🧹 Step 2: Remove Supporting Files

Check and remove any leftover files in these common locations:

bash

rm -rf ~/Library/Application\ Support/aDrive
rm -rf ~/Library/Preferences/com.adrive.*
rm -rf ~/Library/Caches/com.adrive.*
rm -rf ~/Library/Logs/aDrive

You can also search more broadly:

bash

find ~/Library -iname "*adrive*" -exec rm -rf {} +

🧾 Step 3: Remove Installer Receipts

Check for receipts:

bash

ls /var/db/receipts | grep -i adrive

If found, remove them:

bash

sudo rm /var/db/receipts/com.adrive.*

🔍 Step 4: Check for Background Services

See if any launch agents or daemons are running:

bash

launchctl list | grep -i adrive

If you find any, unload and delete them:

bash

launchctl bootout system /Library/LaunchDaemons/com.adrive.*
sudo rm /Library/LaunchDaemons/com.adrive.*

Also check:

bash

launchctl bootout user/$(id -u) ~/Library/LaunchAgents/com.adrive.*
rm ~/Library/LaunchAgents/com.adrive.*

✅ Final Check

Run this to confirm it's gone:

bash

ps aux | grep -i adrive
lsof -i | grep -i adrive

If nothing shows up, you're clean!


Here's a reusable macOS app uninstaller script that you can customize for any app. It automates the steps we discussed and prompts you for the app name.

  • ✅ Auto-resolved internal name and full bundle ID

  • ✅ Accurate detection of preferences and launch agents using CFBundleIdentifier

  • ✅ Dry-run and verbose modes

  • ✅ Login item removal

  • ✅ Process inspection

  • ✅ Log file creation

🧰 Script: uninstall_app.sh

#!/bin/zsh

# === CONFIG ===
DRY_RUN=false
VERBOSE=false

# === PARSE FLAGS ===
for arg in "$@"; do
  case $arg in
    --dry-run) DRY_RUN=true ;;
    --verbose) VERBOSE=true ;;
  esac
done

# === INPUT ===
read "app_name?Enter the app name (e.g., 字由): "

# === FIND APP PATH ===
app_path=$(mdfind "kMDItemDisplayName == '$app_name'" | head -n 1)

if [[ -z "$app_path" ]]; then
  echo "❌ App '$app_name' not found via Spotlight."
  exit 1
fi

# === READ BUNDLE INFO ===
bundle_id=$(defaults read "$app_path/Contents/Info" CFBundleIdentifier 2>/dev/null)
bundle_name=$(defaults read "$app_path/Contents/Info" CFBundleName 2>/dev/null)
internal_name="${bundle_id##*.}"  # e.g. com.electron.hellofont → hellofont

# === LOG FILE ===
log_file="$HOME/uninstall_${app_name}_$(date +%Y%m%d_%H%M%S).log"

echo "🔧 Preparing to uninstall $app_name"
[[ $DRY_RUN == true ]] && echo "🧪 Dry-run mode enabled. No files will be deleted."
echo "📄 Log file: $log_file"

read "confirm?⚠️ Are you sure you want to proceed with ${DRY_RUN:+dry-run }uninstalling $app_name? (y/N): "
[[ $confirm != "y" ]] && echo "❌ Cancelled." && exit 1

echo "✅ Proceeding..."

# === VERBOSE DIAGNOSTICS ===
if [[ $VERBOSE == true ]]; then
  echo "🔍 Verbose mode:"
  echo "  • Display name: $app_name"
  echo "  • App path: $app_path"
  echo "  • Bundle ID: $bundle_id"
  echo "  • Bundle Name: $bundle_name"
  echo "  • Internal name: $internal_name"
fi

# === PROCESS CHECK ===
echo "🔍 Checking for running processes related to $app_name..."
pgrep -fl "$app_name" | tee -a "$log_file"

# === FILE PATHS ===
paths=(
  "$app_path"
  "$HOME/Library/Application Support/$internal_name"
  "$HOME/Library/Preferences/$bundle_id.plist"
  "$HOME/Library/LaunchAgents/$bundle_id.plist"
  "/Library/LaunchAgents/$bundle_id.plist"
  "/Library/LaunchDaemons/$bundle_id.plist"
)

echo "🗑️ Removing app files..."
for path in "${paths[@]}"; do
  if [[ -e "$path" ]]; then
    echo "Found: $path"
    if [[ $DRY_RUN == false ]]; then
      rm -rf "$path"
      echo "Deleted: $path"
    else
      echo "Would delete: $path"
    fi
  else
    echo "Not found: $path"
  fi
done

# === LOGIN ITEM REMOVAL ===
echo "🔒 Checking for login items named '$app_name'..."
if [[ $DRY_RUN == false ]]; then
  osascript <<EOF
tell application "System Events"
  if login item "$app_name" exists then
    delete login item "$app_name"
  end if
end tell
EOF
else
  echo "Would run AppleScript to remove login item named '$app_name'"
fi

echo "✅ Uninstallation ${DRY_RUN:+dry-run }complete."

🛠️ How to Use

  1. Save the script as uninstall_app.sh

  2. Make it executable:

bash

chmod +x uninstall_app.sh
  1. Run it:

  • Dry-run preview:

zsh

./uninstall_app_dryrun.zsh --dry-run --verbose
  • Actual uninstall:

zsh

./uninstall_app_dryrun.zsh

https://github.com/erikstam/uninstaller/blob/main/uninstaller.shhttps://github.com/erikstam/uninstaller/blob/main/uninstaller.sh


网站公告

今日签到

点亮在社区的每一天
去签到