androidadbpackagemaker

delete packages of domain by adb shell pm


There is a command to ease the pain of managing packages for Android phone,

adb shell pm uninstall org.kde.necessitas.example.one
adb shell pm uninstall org.kde.necessitas.example.two

But I have many phones and just want to delete all packages from a particular domain on them.

It cannot be done by

adb shell pm uninstall org.kde.necessitas.example.*

what is your suggestion?


Solution

  • You can use the following in a batch file: (I am assuming Windows though)

      adb shell pm list packages org.kde.necessitas.example > packages.txt
    
      for /F "tokens=2 delims=:" %%a in (packages.txt) do adb shell pm uninstall %%a
    

    You could take it a step further and make the search text a parameter:

      adb shell pm list packages %1 > packages.txt
    
      for /F "tokens=2 delims=:" %%a in (packages.txt) do adb shell pm uninstall %%a
    

    This pipes the output of the pm list packages command into a text file and then loops through each line of the text file. It calls adb shell pm uninstall for each second token in the line which in this case is the package name.