General Permission Denier Tool

Search This thread


May 19, 2022
Samsung Galaxy A32 5G
Hey! This is like my first genuine post anywhere on XDA besides my introduction, but I got really fed up today with typing out ADB commands manually and created myself a little menu to deny permissions using APPOPS, and I decided to share it. This is a .BAT file or a Windows batch file. Make sure that if you want to use this script, you put it in the same folder as adb.exe. This should generally work for any Android device, not just the Galaxy A32 5G.
@echo off
set currentlocation=menu
echo Package Permission Denier by Platless.
goto appops

set currentlocation=appops
echo What is the name of the package?
set /p "packname=>"
adb shell pm list packages ^| grep -x package:%packname%
if %errorlevel% == 1 goto notapackage
adb shell appops get %packname% ^| grep -v deny > temp.txt
for %%I in (temp.txt) do echo %%~zI > output.txt
set /p size=<output.txt
del output.txt
if %size% == 0 goto noperms
set COUNT=0

for /F %%i in ( temp.txt ) do (
  set /A COUNT=!COUNT! + 1
  echo !COUNT!: %%i
  set perm[!COUNT!]=%%i

  set choice=!choice!!COUNT!

if %COUNT% LSS 10 (
choice /C %choice% /M "Type the number of the permission you want to deny."
set permnumber=!ERRORLEVEL!
) else set  /P permnumber="Type the number of the permission you want to deny.: "
set permthing=!perm[%permnumber%]::= !
adb shell appops set %packname% %permthing% deny
del temp.txt
goto %currentlocation%

echo This app either doesn't have any permissions or they are all denied. Well done.
goto menu

echo Package not found.
adb shell pm list packages ^| grep -w %packname% > didyoumean.txt
set /p didyoumean= <didyoumean.txt
for %%I in (didyoumean.txt) do echo %%~zI > size.txt
set /p size=<size.txt
del size.txt
del didyoumean.txt
if %size% == 0 goto %currentlocation%
echo Did you mean%didyoumean:package:= %?
goto %currentlocation%