Use python to write bulk uninstall android application scripts installed on the phone
- 2020-04-02 13:53:02
- OfStack
The function of this script is to uninstall all third-party apps installed in android phones, mainly using adb shell PM and adb uninstall commands. Therefore, the premise of using this script is that the environment variables of adb need to be properly configured.
#!/usr/bin/env python
import os
def uninstall():
os.popen("adb wait-for-device")
print "start uninstall..."
for packages in os.popen("adb shell pm list packages -3").readlines():
packageName = packages.split(":")[-1].splitlines()[0]
os.popen("adb uninstall " + packageName)
print "uninstall " + packageName + " successed."
if __name__ == "__main__":
uninstall()
print " "
print "All the third-party applications uninstall successed."