Skip to content

Instantly share code, notes, and snippets.

@shvchk
Last active July 28, 2023 06:54
Show Gist options
  • Save shvchk/cff2eb87df0b4d0d242129fe36c14d33 to your computer and use it in GitHub Desktop.
Save shvchk/cff2eb87df0b4d0d242129fe36c14d33 to your computer and use it in GitHub Desktop.
Uninstall list of apps with adb | Usage: ./adb-uninstall.sh <file with apps list> | Example: ./adb-uninstall.sh bloatware.txt or ./adb-uninstall.sh https://example.com/bloatware.txt | Video demo: https://youtu.be/knvvIPyttRs
#! /usr/bin/env bash
set -euo pipefail
[[ -v 1 ]] || { echo "Usage: $(basename -- "$0") <file/URL with apps list>"; exit 1; }
echo "Waiting for device"
adb wait-for-device
if [[ $1 == https://* ]]; then
apps="$(wget -qO- "$1")"
else
apps="$(< "$1")"
fi
while IFS="" read -r app || [[ -n $app ]]; do
[[ -n $app && $app != \#* ]] || continue
result="$(adb exec-out pm uninstall --user 0 "$app")"
echo "$app - $result"
if [[ $result = "Failure [-1000]" ]]; then
echo "! $app uninstall failed, trying to disable"
adb exec-out pm disable-user "$app"
fi
done <<< "$apps"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment