Last active
August 19, 2023 01:52
-
-
Save and2long/f2feb2fd486325a5db81eae99d5f5839 to your computer and use it in GitHub Desktop.
(安卓)一键卸载第三方程序脚本。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string=$(adb devices | egrep ".*device$") | |
devices=(${string//device/}) | |
echo "检测到${#devices[@]}台设备连接" | |
for ((i = 0; i < ${#devices[*]}; i++)); do | |
echo "$(($i + 1)). ${devices[i]} : $(adb -s ${devices[i]} shell getprop ro.product.model)" | |
done | |
if [ ${#devices[@]} -gt 0 ]; then | |
echo "输入要操作的设备编号:" | |
read num | |
case $num in | |
[1-9]) | |
d=${devices[$(($num - 1))]} | |
name=$(adb -s $d shell getprop ro.product.model) | |
echo "操作 $name" | |
string=$(adb -s $d shell pm list packages -3) | |
packages=(${string// /}) | |
echo "发现${#packages[@]}个第三方程序:" | |
for item in ${packages[@]}; do | |
echo ${item//package:/} | |
done | |
echo "确定要全部卸载吗?(y/n)" | |
read c | |
if [ $c = "y" ]; then | |
for ((i = 0; i < ${#packages[@]}; i++)); do | |
item=${packages[i]} | |
p=${item//package:/} | |
progress="$((i + 1))/${#packages[@]}" | |
echo "$progress uninstall $p $(adb -s $d uninstall $p)" | |
done | |
fi | |
;; | |
*) | |
echo "非法输入" | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment