I would like to setup a tasker profile to check every predetermined time for any apps not on my approved list (BaselineApps.txt) and uninstall them. I am a noob to shell scripting and tasker. This is what I got so far, it might not be the most efficient way to do it.

  • I run the following command via Termux Task plugin.

    pm list packages >/storage/emulated/0/Apps.txt
    diff --unchanged-line-format= --old-line-format= --new-line-format='%L' /storage/emulated/0/BaselineApps.txt /storage/emulated/0/Apps.txt | sed 's/^[^:]*://' >/storage/emulated/0/NewApps.txt
  • Read file NewApps.txt to variable %Apps

  • ArraySet %Apps value %Apps

  • For each %eachapp in %Apps()

  • Run Shell pm uninstall %eachapp
  • End for

For the most part it works, except it errors out sometimes. Can someone help me?

1 Answer 1


So I figured out my issue. I had upgraded to Android Nougat. Pm list packages is obsolete. The proper command is pm cmd package list packages.

Here is my setup:

    A1: Run Shell [ Command:cmd package list packages Timeout (Seconds):0 Use Root:On Store Output In:%tempapps Store Errors In: Store Result In: ] 
    A2: Write File [ File:Apps.txt Text:%tempapps Append:Off Add Newline:Off ] 
    A3: Termux [ Configuration:Execute ~/.termux/tasker/DiffApps.txt  Timeout (Seconds):0 ] 
    A4: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ] 
    A5: Read File [ File:NewApps.txt To Var:%Apps ] 
    A6: Array Set [ Variable Array:%Apps Values:%Apps Splitter: ] 
    A7: For [ Variable:%eachapp Items:%Apps() ] 
    A8: Flash [ Text:%eachapp Long:On ] 
    A9: Run Shell [ Command:pm uninstall %eachapp Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ] 
    A10: End For 
    A11: Variable Clear [ Name:apps* Pattern Matching:On Local Variables Only:Off ] 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .