General Permission Denier Tool - 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.
Code:
@echo off
:menu
set currentlocation=menu
echo Package Permission Denier by Platless.
goto appops
: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
setlocal ENABLEDELAYEDEXPANSION
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
pause
goto %currentlocation%
:noperms
echo This app either doesn't have any permissions or they are all denied. Well done.
pause
goto menu
:notapackage
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%

Related

[Script]Universal Quick Flasher

While I was pushing some files trough adb I thought it would be handy to have a script which automates it, a simple bat file in this case, can become very handy if you need to push some system apps for testing. It will show several reboot options afterwards and additionally it can flash a kernel to your device.
I know it's better to just upgrade my Quick Flasher tool, but this was written in 10 min so why not share and upgrade later
co credits:
- stepie22 (helped me in expanding it)
It requires adb in it's directory and the files you want to push as well.
Kernelflasher.bat:
Code:
@echo off
REM /*
REM * cd to the current directory
REM */
cd /d %~dp0
mode con:lines=30
REM /*
REM * Check if adb is available in the path variable, the default path or the current directory.
REM * Asks user if they want to download it if it is not found.
REM */
set found=
set quotedPath="%PATH:;="; "%"
set prog=adb.exe
for %%i in (%quotedPath%) do if exist %%i\%prog% set found=%%i
:adbdetected
REM /*
REM * Added incase usb isn't properly connected
REM */
title Universal Quick Flasher v1.04 - Waiting for device...
echo Waiting for device...
echo Please plugin android device with usb debugging enabled
adb wait-for-device
cls
adb root
adb remount
title Universal Quick Flasher v1.04
goto main
if not ""==%found% goto adbdetected
if exist adb.exe goto adbdetected
if exist "%programfiles%\Android\android-sdk\platform-tools\adb.exe" goto adbdetected
REM /*
REM * Added Windows 7 Default location for android-sdk
REM */
if exist "%USERPROFILE%\android-sdks\platform-tools\adb.exe" goto adbdetected
if exist "%USERPROFILE%\android-sdk\platform-tools\adb.exe" goto adbdetected
goto noadb
:main
cls
echo.
echo *************************************
echo * Universal Quick Flasher v1.04 *
echo * *
echo * By broodplank1337 *
echo * and *
echo * stepie22 *
echo * *
echo * All Filenames are CaseSensitive! *
echo *************************************
echo.
echo What do you want to flash?
echo.
echo [1] App (system app or regular app)
echo [2] Kernel
echo.
echo Optional
echo.
echo [3] Reboot
echo [4] Visit project page
echo.
echo [79] exit
echo.
echo.
set /p choice=:
if "%choice%"=="1" goto app
if "%choice%"=="2" goto kernel
if "%choice%"=="3" goto rmenu
if "%choice%"=="4" goto ppage
if "%choice%"=="79" goto exit
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%choice%'.
pause
goto main
:kernel
cls
echo.
echo Enter kernel name (zImage or boot.img)
set /p kername= Kernel name:
echo.
echo Enter kernel partition number
echo As in (/dev/block/mmcblk0p*) where * is your number
set /p kernum= Kernel Partition Number:
echo.
cls
:kernelck
REM /*
REM * Display for rewiew
REM */
echo.
echo Kernel name: %kername%
echo FLash to : /dev/block/mmcblk0p%kernum%
echo.
set /p valid=Correct (y or n):
if "%valid%"=="y" goto kernelcont
if "%valid%"=="Y" goto kernelcont
if "%valid%"=="n" goto kernel
if "%valid%"=="N" goto kernel
set msg=Incorrent option
goto kernelck
:kernelcont
if not exist %kername% (
set returnto=kernel
goto nofile
)
echo.
echo Flashing %kername% to /dev/block/mmcblk0p%kernum%
adb push %kername% /sdcard/%kername%
adb -d shell su -c "dd if=/sdcard/%kername% of=/dev/block/mmcblk0p%kernum%"
echo.
echo Done! Rebooting Device...
echo.
adb reboot
pause
goto goagain
:app
set /p name=APK Name:
cls
echo.
echo APK Name: %name%
echo APK Type:
echo.
echo [1] System App (/system/app)
echo [2] Framework App (/system/framework)
echo [3] Regular App (/data/system)
echo.
set /p type=:
if "%type%"=="1" goto sysapp
if "%type%"=="2" goto frameapp
if "%type%"=="3" goto normapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%type%'.
pause
cls
goto app
:sysapp
if not exist %name% (
set returnto=app
goto nofile
)
adb push %name% /system/app/%name%
adb -d shell chmod 644 /system/app/%name%
cls
echo.
echo Do you want to reboot your device (y/n)?
echo.
set /p choice=:
if "%choice%"=="n" goto goagain
if "%choice%"=="N" goto goagain
if "%choice%"=="y" goto rmenu
if "%choice%"=="Y" goto rmenu
echo ERROR, no option found for '%choice%'
pause
goto sysapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%reboot%'.
pause
cls
goto sysapp
:frameapp
if not exist %name% (
set returnto=app
goto nofile
)
adb push %name% /system/framework/%name%
adb -d shell chmod 644 /system/framework/%name%
cls
echo.
echo Do you want to reboot your device (y/n)?
echo.
set /p choice=:
if "%choice%"=="n" goto goagain
if "%choice%"=="N" goto goagain
if "%choice%"=="y" goto rmenu
if "%choice%"=="Y" goto rmenu
echo ERROR, no option found for '%choice%'
pause
goto frameapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%reboot%'.
pause
cls
goto frameapp
:normapp
if not exist %name% (
set returnto=app
goto nofile
)
adb install %name%
goto goagain
:rmenu
cls
echo.
echo [1] Shutdown
echo [2] Reboot Normaly
echo [3] Reboot fast
echo [4] Reboot into Recovery
echo [5] Reboot into Bootloader (Download Mode)
echo [9] Main Menu
echo [79] Exit
echo.
set /p rmenu=:
if "%rmenu%"=="1" goto shutdown
if "%rmenu%"=="2" goto reboot
if "%rmenu%"=="3" goto rebootf
if "%rmenu%"=="4" goto rebootr
if "%rmenu%"=="5" goto rebootdl
if "%rmenu%"=="9" goto main
if "%rmenu%"=="79" goto exit
echo.
echo No option found for '%rmenu%'
pause
goto rmenu
:ppage
start http://broodplank.net/?p=729
goto main
:shutdown
echo.
echo Shutting down device.
adb shell reboot -p
goto goagain
:reboot
echo.
echo Rebooting Device Completely.
adb reboot
echo Done!
goto goagain
:rebootf
echo.
echo Rebooting Device Fast (kill system_server)
adb -d shell su -c "busybox killall system_server"
echo Done!
goto goagain
:rebootr
echo.
echo Rebooting Device into Recovery.
adb reboot recovery
goto goagain
:rebootdl
echo.
echo Rebooting Device into Bootloader (Download Mode)
adb reboot bootloader
goto goagain
:nofile
cls
echo.
echo ********************************
echo * That file could not be found *
echo ********************************
echo.
echo Press enter to try again.
set /p nofile=
goto %returnto%
:noadb
cls
echo.
echo ************************
echo * ADB was not detected *
echo ************************
echo.
echo Download?? (y/n)
set /p choice=:
if "%choice%"=="n" goto exit
if "%choice%"=="N" goto exit
if "%choice%"=="y" goto dl
if "%choice%"=="Y" goto dl
echo ERROR, no option found for '%choice%'
pause
goto noadb
:dl
cls
echo.
echo ************************
echo * ADB was not detected *
echo ************************
echo.
echo Downloading adb.rar from broodplank.net...
echo Extract it in: %~dp0
start http://broodplank.net/files/ADB.rar
pause
goto exit
:goagain
cls
echo.
echo Press m to go to the Main Menu,
echo Press any other key to exit.
echo.
set /p goagain=:
if "%goagain%"=="m" goto main
if "%goagain%"=="M" goto main
:exit
echo.
echo.
echo Exiting...
pause
exit
Really useful one..thank u..
Sent from my GT-I9001 using Tapatalk 2
VERY VERY NICE SCRIPT! Omg you're a monster
Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
lontu said:
Really useful one..thank u..
Sent from my GT-I9001 using Tapatalk 2
Click to expand...
Click to collapse
You're welcome
umb3rts said:
VERY VERY NICE SCRIPT! Omg you're a monster
Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
Click to expand...
Click to collapse
Haha, I develop all the time (like 90% of the time that I spend on my computer) so I have a lot of things like these. I will keep producing more and more without question
Usefull as always..
The tools and roms are growing like trees here. I cant update the index on androidworld so fast :silly:
I wish I had enough free time to spend on developing, i have some ideas sometime... but not enough time to learn/write, altough i'm a native Linux user. brood, you are fantastic as always
Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
if i may give you an idea:
you could write an app which does basically this
Code:
:rebootf
echo.
echo Rebooting Device Fast (kill system_server)
adb -d shell su -c "busybox killall system_server"
echo Done!
exit
untill now i had to kill system_server using terminal emulator.
Hey Brood.
Could you make something like a bat to get quick to my adb.exe? I hate it to cd through all the directorys to get to it.
Example:
I want to go to cmd.exe then type "adb" then for example "adb devices" and adb should start? Is that possible?
P.S: As always i love your work. The script is really nice and wellmade with the logo and etc
mrjraider said:
Usefull as always..
The tools and roms are growing like trees here. I cant update the index on androidworld so fast :silly:
Click to expand...
Click to collapse
Thanks and yes it's growing very fast idd!
umb3rts said:
I wish I had enough free time to spend on developing, i have some ideas sometime... but not enough time to learn/write, altough i'm a native Linux user. brood, you are fantastic as always
Inviato dal mio GT-I9001 che di originale non ha più nulla con la CyanogenMod RC1 usando Tapatalk 2.
Click to expand...
Click to collapse
The key is to not spend your computer time on gaming but on developing hehe (works for me). but if you don't have enough time it will become hard
And you're welcome ^^
dr.wtf said:
if i may give you an idea:
you could write an app which does basically this
Code:
:rebootf
echo.
echo Rebooting Device Fast (kill system_server)
adb -d shell su -c "busybox killall system_server"
echo Done!
exit
untill now i had to kill system_server using terminal emulator.
Click to expand...
Click to collapse
Of course I can make that, I'm in linux right now so when i'm back in windows, I will make the app and send it to you.
XeLLaR* said:
Hey Brood.
Could you make something like a bat to get quick to my adb.exe? I hate it to cd through all the directorys to get to it.
Example:
I want to go to cmd.exe then type "adb" then for example "adb devices" and adb should start? Is that possible?
P.S: As always i love your work. The script is really nice and wellmade with the logo and etc
Click to expand...
Click to collapse
Yes that can be achieved by adding: "cd /d %~dp0" in the batch script, the command will automatically cd to it's directory.
And you need to enter "adb shell" to enter the adb shell , else it will close.
adb shell > normal shell usage
adb -d shell ".." > command here
And you're welcome btw
broodplank1337 said:
Yes that can be achieved by adding: "cd /d %~dp0" in the batch script, the command will automatically cd to it's directory.
And you need to enter "adb shell" to enter the adb shell , else it will close.
adb shell > normal shell usage
adb -d shell ".." > command here
And you're welcome btw
Click to expand...
Click to collapse
Thank you very much!! :good:
Hey Brood do you know a nice howto about building an app wich base is a batch file ? Or is ot not possible to buold an android app with batch commands ?
Sent from my GT-I9001 using xda app-developers app
Diablob555 said:
Hey Brood do you know a nice howto about building an app wich base is a batch file ? Or is ot not possible to buold an android app with batch commands ?
Sent from my GT-I9001 using xda app-developers app
Click to expand...
Click to collapse
i think that its impossible because DOS uses its own functions. means that batch commands are especially for windows.
Sent from my GT-I9001 using xda app-developers app
So I'll need java commands ?
Sent from my GT-I9001 using xda app-developers app
What, you haven't updated it here? I feel offended! Na, just joking.
To people who don't know what I'm talking about: http://broodplank.net/?p=729
Sent from my GT-I9001 using xda app-developers app
stepie22 said:
What, you haven't updated it here? I feel offended! Na, just joking.
To people who don't know what I'm talking about: http://broodplank.net/?p=729
Sent from my GT-I9001 using xda app-developers app
Click to expand...
Click to collapse
True, well it's my site so it's not very strange if it gets priority but it's good that you take a look at my site, it has more hidden stuff
v1.4
Code:
@echo off
REM /*
REM * cd to the current directory
REM */
cd /d %~dp0
mode con:lines=30
REM /*
REM * Check if adb is available in the path variable, the default path or the current directory.
REM * Asks user if they want to download it if it is not found.
REM */
set found=
set quotedPath="%PATH:;="; "%"
set prog=adb.exe
for %%i in (%quotedPath%) do if exist %%i\%prog% set found=%%i
:adbdetected
REM /*
REM * Added incase usb isn't properly connected
REM */
title Universal Quick Flasher v1.04 - Waiting for device...
echo Waiting for device...
echo Please plugin android device with usb debugging enabled
adb wait-for-device
cls
adb root
adb remount
title Universal Quick Flasher v1.04
goto main
if not ""==%found% goto adbdetected
if exist adb.exe goto adbdetected
if exist "%programfiles%\Android\android-sdk\platform-tools\adb.exe" goto adbdetected
REM /*
REM * Added Windows 7 Default location for android-sdk
REM */
if exist "%USERPROFILE%\android-sdks\platform-tools\adb.exe" goto adbdetected
if exist "%USERPROFILE%\android-sdk\platform-tools\adb.exe" goto adbdetected
goto noadb
:main
cls
echo.
echo *************************************
echo * Universal Quick Flasher v1.04 *
echo * *
echo * By broodplank1337 *
echo * and *
echo * stepie22 *
echo * *
echo * All Filenames are CaseSensitive! *
echo *************************************
echo.
echo What do you want to flash?
echo.
echo [1] App (system app or regular app)
echo [2] Kernel
echo.
echo Optional
echo.
echo [3] Reboot
echo [4] Visit project page
echo.
echo [79] exit
echo.
echo.
set /p choice=:
if "%choice%"=="1" goto app
if "%choice%"=="2" goto kernel
if "%choice%"=="3" goto rmenu
if "%choice%"=="4" goto ppage
if "%choice%"=="79" goto exit
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%choice%'.
pause
goto main
:kernel
cls
echo.
echo Enter kernel name (zImage or boot.img)
set /p kername= Kernel name:
echo.
echo Enter kernel partition number
echo As in (/dev/block/mmcblk0p*) where * is your number
set /p kernum= Kernel Partition Number:
echo.
cls
:kernelck
REM /*
REM * Display for rewiew
REM */
echo.
echo Kernel name: %kername%
echo FLash to : /dev/block/mmcblk0p%kernum%
echo.
set /p valid=Correct (y or n):
if "%valid%"=="y" goto kernelcont
if "%valid%"=="Y" goto kernelcont
if "%valid%"=="n" goto kernel
if "%valid%"=="N" goto kernel
set msg=Incorrent option
goto kernelck
:kernelcont
if not exist %kername% (
set returnto=kernel
goto nofile
)
echo.
echo Flashing %kername% to /dev/block/mmcblk0p%kernum%
adb push %kername% /sdcard/%kername%
adb -d shell su -c "dd if=/sdcard/%kername% of=/dev/block/mmcblk0p%kernum%"
echo.
echo Done! Rebooting Device...
echo.
adb reboot
pause
goto goagain
:app
set /p name=APK Name:
cls
echo.
echo APK Name: %name%
echo APK Type:
echo.
echo [1] System App (/system/app)
echo [2] Framework App (/system/framework)
echo [3] Regular App (/data/system)
echo.
set /p type=:
if "%type%"=="1" goto sysapp
if "%type%"=="2" goto frameapp
if "%type%"=="3" goto normapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%type%'.
pause
cls
goto app
:sysapp
if not exist %name% (
set returnto=app
goto nofile
)
adb push %name% /system/app/%name%
adb -d shell chmod 644 /system/app/%name%
cls
echo.
echo Do you want to reboot your device (y/n)?
echo.
set /p choice=:
if "%choice%"=="n" goto goagain
if "%choice%"=="N" goto goagain
if "%choice%"=="y" goto rmenu
if "%choice%"=="Y" goto rmenu
echo ERROR, no option found for '%choice%'
pause
goto sysapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%reboot%'.
pause
cls
goto sysapp
:frameapp
if not exist %name% (
set returnto=app
goto nofile
)
adb push %name% /system/framework/%name%
adb -d shell chmod 644 /system/framework/%name%
cls
echo.
echo Do you want to reboot your device (y/n)?
echo.
set /p choice=:
if "%choice%"=="n" goto goagain
if "%choice%"=="N" goto goagain
if "%choice%"=="y" goto rmenu
if "%choice%"=="Y" goto rmenu
echo ERROR, no option found for '%choice%'
pause
goto frameapp
REM /*
REM * Display error if no valid option was chosen
REM */
echo Error, no option found for '%reboot%'.
pause
cls
goto frameapp
:normapp
if not exist %name% (
set returnto=app
goto nofile
)
adb install %name%
goto goagain
:rmenu
cls
echo.
echo [1] Shutdown
echo [2] Reboot Normaly
echo [3] Reboot fast
echo [4] Reboot into Recovery
echo [5] Reboot into Bootloader (Download Mode)
echo [9] Main Menu
echo [79] Exit
echo.
set /p rmenu=:
if "%rmenu%"=="1" goto shutdown
if "%rmenu%"=="2" goto reboot
if "%rmenu%"=="3" goto rebootf
if "%rmenu%"=="4" goto rebootr
if "%rmenu%"=="5" goto rebootdl
if "%rmenu%"=="9" goto main
if "%rmenu%"=="79" goto exit
echo.
echo No option found for '%rmenu%'
pause
goto rmenu
:ppage
start http://broodplank.net/?p=729
goto main
:shutdown
echo.
echo Shutting down device.
adb shell reboot -p
goto goagain
:reboot
echo.
echo Rebooting Device Completely.
adb reboot
echo Done!
goto goagain
:rebootf
echo.
echo Rebooting Device Fast (kill system_server)
adb -d shell su -c "busybox killall system_server"
echo Done!
goto goagain
:rebootr
echo.
echo Rebooting Device into Recovery.
adb reboot recovery
goto goagain
:rebootdl
echo.
echo Rebooting Device into Bootloader (Download Mode)
adb reboot bootloader
goto goagain
:nofile
cls
echo.
echo ********************************
echo * That file could not be found *
echo ********************************
echo.
echo Press enter to try again.
set /p nofile=
goto %returnto%
:noadb
cls
echo.
echo ************************
echo * ADB was not detected *
echo ************************
echo.
echo Download?? (y/n)
set /p choice=:
if "%choice%"=="n" goto exit
if "%choice%"=="N" goto exit
if "%choice%"=="y" goto dl
if "%choice%"=="Y" goto dl
echo ERROR, no option found for '%choice%'
pause
goto noadb
:dl
cls
echo.
echo ************************
echo * ADB was not detected *
echo ************************
echo.
echo Downloading adb.rar from broodplank.net...
echo Extract it in: %~dp0
start http://broodplank.net/files/ADB.rar
pause
goto exit
:goagain
cls
echo.
echo Press m to go to the Main Menu,
echo Press any other key to exit.
echo.
set /p goagain=:
if "%goagain%"=="m" goto main
if "%goagain%"=="M" goto main
:exit
echo.
echo.
echo Exiting...
pause
exit

[SCRIPT] Common ADB/FASTBOOT Functions

DISCLAIMER: I TAKE NO RESPONSIBILITY FOR DAMAGE CAUSED TO ANYONE OR ANYTHING BY USING MY SCRIPT. USE THIS AT YOUR OWN RISK.
So pretty much this is a script that can:
1. Flash a new boot animation without going through all the hassle of entering remounting commands. (Main reason why I wrote this) (Requires root and maybe adb insecure by chainfire)
2. Flash a new startup logo. (Requires unlocked bootloader)
3. Basic reboot commands with the press of a number.
4. Push and Pull files without entering commands, just need to specify the file location by dragging and dropping into the command window. (Some cases may need root. If your case does not need root, and the script says failed to restart adb as root, your command will still work, hopefully)
5. Install an apk the same way as 4. (If it says failed to restart as root it will still work in most cases)
6. Extremely noob friendly :laugh:.
Just a small little script to make your life a bit easier.
I tested this numerous times on a Moto G xt1032 running cyanogenmod 11 m4 and it showed no flaws. If this does not work for you try installing adb insecure by chainfire.
This works on windows only (I think).
If you find any bugs please tell me and I will try to fix even though I am just starting out with the wonders of developing. Some of the functions of the script need root access!
To use this, just copy and paste the lines below into a notepad window. Then save the file as something.bat Make sure to change the dropdown menu from txt document to all files when saving. Put the script in the folder where adb.exe and fastboot.exe are located. Double-click and enjoy!
Press "Click to show content" below!
@ECHO off
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo IF YOUR DEVICE IS LISTED BELOW TYPE 1
echo ELSE TYPE 2 TO EXIT
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb devices
SET /p startcheck= Type your choice:
if "%startcheck%" =="1" goto menu
if "%startcheck%" =="2" goto exit
:menu
cls
echo Type 0 for Device Check
echo Type 1 to Flash Boot Animation (ADB root required)
echo Type 2 to Flash Startup Logo
echo Type 3 to Reboot to Bootloader
echo Type 4 to Reboot
echo Type 5 to Pull a File
echo Type 6 to Push a File
echo Type 7 to Install Apk
echo Type 8 to Run ADB as Root
echo Type 9 to Browse and Copy Apps to Computer (ADB root required)
echo Type 10 to Browse and Copy SYSTEM Apps to Computer (ADB root required)
echo Type 11 to Exit
SET /p choice= Type your choice:
if "%choice%" =="0" goto devcheck
if "%choice%" =="1" goto anim
if "%choice%" =="2" goto logo
if "%choice%" =="3" goto rebootloader
if "%choice%" =="4" goto reboot
if "%choice%" =="5" goto adbpull
if "%choice%" =="6" goto adbpush
if "%choice%" =="7" goto apk
if "%choice%" =="8" goto adbroot
if "%choice%" =="9" goto apps
if "%choice%" =="10" goto sysapps
if "%choice%" =="11" goto exit
goto end
:end
cls
echo Type 1 to restart program
echo Type 2 to exit
SET /p restart= Type your choice
if "%restart%" =="1" goto menu
if "%restart%" =="2" goto exit
:exit
exit
:anim
cls
adb kill-server
adb start-server
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo IF YOUR DEVICE IS LISTED BELOW TYPE 1
echo ELSE TYPE 2 TO EXIT
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb devices
SET /p adb= Type your choice
if "%adb%" =="2" goto menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR YOUR bootanimation.zip
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p bapath= Type your path here and press enter:
cls
adb wait-for-device root
timeout -t 1 > nul
echo Remounting system in read-write mode!
adb wait-for-device remount
timeout -t 2 > nul
adb wait-for-device shell "su -c 'mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system'"
echo Deleting existing bootanimation!
adb wait-for-device shell "su -c 'rm /system/media/bootanimation.zip'"
echo Sending new bootanimation!
adb push %bapath% /system/media
echo Remounting system in read-only mode!
adb wait-for-device shell "su -c 'mount -o ro,remount -t yaffs2 /dev/block/mtdblock1 /system'"
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press 1 to reboot!
echo Press 2 to exit!
SET /p dm= Type your choice
if "%dm%" =="1" goto reboot
if "%dm%" =="2" goto end
:logo
cls
echo Rebooting to bootloader...
adb reboot-bootloader
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo When device is in bootloader press any key to continue!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PAUSE
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo IF YOUR DEVICE IS LISTED BELOW TYPE 1
echo ELSE TYPE 2 TO EXIT
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fastboot devices
SET /p fbdev= Type your choice
if "%fbdev%" =="2" goto menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR YOUR logo.bin
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p lopath= Type your path here and press enter:
cls
echo Sending new logo!
fastboot flash logo %lopath%
echo Rebooting...
fastboot reboot
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press any key to return to menu!
PAUSE
goto menu
:reboot
cls
adb reboot
echo Rebooting...
timeout -t 3 > nul
goto menu
:rebootloader
cls
adb reboot-bootloader
echo Rebooting to bootloader...
timeout -t 3 > nul
goto menu
:adbpull
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR THE FILE TO PULL
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p adbpullpath= Type your path here and press enter:
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR THE FILE TO SAVE
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p adbpullsave= Type your path here and press enter:
cls
echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!!
timeout -t 2 > nul
echo Pulling File!
adb wait-for-device pull %adbpullpath% %adbpullsave%
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press any key to return to menu!
PAUSE
goto menu
:adbpush
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR THE FILE TO PUSH
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p adbpushpath= Type your path here and press enter:
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR THE DIRECTORY TO PUSH TO
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p adbpushsave= Type your path here and press enter:
cls
echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!!
timeout -t 2 > nul
echo Pushing File!
adb wait-for-device push %adbpushpath% %adbpushsave%
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press any key to return to menu!
PAUSE
goto menu
:apk
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo IF YOUR DEVICE IS LISTED BELOW TYPE 1
echo ELSE TYPE 2 TO EXIT
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb devices
SET /p apkcheck= Type your choice
if "%apkcheck%" =="2" goto exit
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR THE APK TO INSTALL
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p apkinstall= Type your path here and press enter:
cls
echo !!!IF THIS ACTION NEEDS ROOT RUN OPTION 8 FROM MENU FIRST!!!
timeout -t 2 > nul
echo Installing Apk!
adb wait-for-device install %apkinstall%
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press any key to return to menu!
PAUSE
goto menu
:devcheck
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo DEVICE CONNECTION CHECK
echo Your device should be listed below!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb devices
PAUSE
goto menu
:adbroot
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Trying to run ADB as root!
adb wait-for-device root
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo !!!ONCE DEVICE RECONNECTS TO COMPUTER PRESS ANY KEY TO GET TO MENU!!!
PAUSE
goto menu
:apps
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb wait-for-device shell "su -c 'ls /data/app'"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Do you want to copy an app to the computer?
set /p appans= (Y or N):
if "%appans%" =="N" goto menu
if "%appans%" =="n" goto menu
if "%appans%" =="no" goto menu
if "%appans%" =="No" goto menu
if "%appans%" =="NO" goto menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb wait-for-device shell "su -c 'ls /data/app'"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Type the app's name EXACTLY including the .apk extension
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set /p appcp= Type the name EXACTLY as it appears:
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Type the destination directory
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set /p appdd= Destination Directory:
cls
echo Copying App!
adb pull /data/app/%appcp% %appdd%
echo Done!
PAUSE
goto menu
:sysapps
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb wait-for-device shell "su -c 'ls /system/app'"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Do you want to copy an app to the computer?
set /p sappans= (Y or N):
if "%sappans%" =="N" goto menu
if "%sappans%" =="n" goto menu
if "%sappans%" =="no" goto menu
if "%sappans%" =="No" goto menu
if "%sappans%" =="NO" goto menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb wait-for-device shell "su -c 'ls /system/app'"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Type the app's name EXACTLY including the .apk extension
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set /p sappcp= Type the name EXACTLY as it appears:
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Type the destination directory
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set /p sappdd= Destination Directory:
cls
echo Copying App!
adb pull /system/app/%sappcp% %sappdd%
echo Done!
PAUSE
goto menu

[SCRIPT] Bootanimation.zip Flasher

This is a simple script that automatically flashes a new boot animation. It does the remount and deletion commands automatically to provide an easy and fast way to flash boot animations.
ADB ROOT command must be functioning for this to work properly.
DISCLAIMER: THE CREATOR IS NOT RESPONSIBLE FOR DAMAGE CAUSED BY THE USE OF THIS SCRIPT! USE THIS AT YOUR OWN RISK!!!
1. Copy the code below into a new notepad window.
2. Save the file as bootanimation flasher.bat in the folder where adb and its components are located. (MAKE SURE YOU HAVE THE .bat EXTENSION)
3. Run the script!
Common Errors:
"error protocol failure" - this error occurs when the command adb root did not function properly. Fix the issue and try again. Try and re-enable usb debugging if it still doesn't work.
Try and use this app to get adb root functioning: http://forum.xda-developers.com/showthread.php?t=1687590
This was tried and tested with success on a oneplus one and a moto g (1st gen)
Script (click button to show):
@echo off
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ROOT ACCESS IS REQUIRED. ADB ROOT COMMAND MUST BE FUNCTIONING.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo THE CREATOR OF THIS SCRIPT IS NOT RESPONSIBLE FOR ANY DAMAGE!
echo USE THIS AT YOUR OWN RISK!!!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PAUSE
cls
echo Starting ADB!
adb kill-server > nul
adb start-server > nul
echo Done!
timeout -t 1 > nul
:menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo IF YOUR DEVICE IS LISTED BELOW TYPE 1
echo TYPE 2 TO TRY AGAIN
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adb devices
SET /p startcheck= Type your choice:
if "%startcheck%" =="1" goto ask
if "%startcheck%" =="2" goto menu
goto menu
:ask
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE 1 TO FLASH BOOTANIMATION!
echo TYPE 2 TO BACKUP EXISTING BOOTANIMATION THEN FLASH!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p askbackup= Type your choice:
if "%askbackup%" =="1" goto anim
if "%askbackup%" =="2" goto backup
goto menu
:backup
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH TO BACKUP BOOTANIMATION TO!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p backuppath= Type your path and press enter:
cls
echo Backing Up!
adb pull /system/media/bootanimation.zip %backuppath%
echo Done
PAUSE
goto anim
:anim
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo TYPE THE PATH FOR YOUR bootanimation.zip
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET /p bapath= Type your path here and press enter:
cls
echo Running command adb root...
adb wait-for-device root > nul
timeout -t 1 > nul
echo Success, Root Access obtained!
echo Remounting system in read-write mode!
adb wait-for-device remount > nul
timeout -t 1 > nul
adb wait-for-device shell "su -c 'mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system'"
echo Remount Succeded!
echo Deleting existing bootanimation!
adb wait-for-device shell "su -c 'rm /system/media/bootanimation.zip'"
echo Sending new bootanimation!
adb push %bapath% /system/media
echo Remounting system in read-only mode!
adb wait-for-device shell "su -c 'mount -o ro,remount -t yaffs2 /dev/block/mtdblock1 /system'"
echo Done!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Press 1 to Reboot!
echo Press 2 to Exit!
SET /p dm= Type your choice
if "%dm%" =="1" goto reboot
if "%dm%" =="2" goto exit
:reboot
cls
echo Rebooting!
adb reboot
timeout -t 1 > nul
PAUSE
:exit
exit

Question Is it possible to do a factory reset without data loss?

Is it possible to do a factory reset without data loss?
To uninstall all apps installed for Android's actual user ( default user 0 ) in one go and also backup actual user's data you can run a Windows CMD script what looks like this draft:
Code:
@echo off & setlocal
set "pc_bkup_fldr=C:\ANDROID-USER-DATA-BKUP"
rem add timestamp in ISO 8601 format to backup folder
for /F "tokens=2 delims==" %%a in ('wmic os get localdatetime /VALUE 2^>NUL') do ( set "datetime=%%a" )
if not "?%datetime%"=="?" (
for /F "tokens=1 delims=." %%a in ("%datetime%") do ( set "retval=%%a" )
if not "?%retval%"=="?" (
set yyyy=%retval:~0,4%
set mm=%retval:~4,2%
set dd=%retval:~6,2%
set "pc_bkup_fldr=%pc_bkup_fldr%-%yyyy%-%mm%-%dd%"
)
)
for /F "skip=1" "tokens=*" %%a in ('adb devices 2^>nul') do ( set "retval=%%a" )
if "?%retval%"=="?" ( goto :end )
mkdir "%pc_bkup_fldr%" 2>nul >nul
rem retrieve user id
for /F %%a in ('adb shell "am get-current-user"') do ( set "uid=%%a" )
rem Below command will return all the android user-app packages installed
rem on the connected Android device.
for /F "tokens=2 delims=:" %%a in ('adb shell "pm list packages --user %uid% -3"') do (
set "pkg_name=%%a"
if not "?%pkg_name%"=="?"
rem clear all application data (including application cache)
adb shell "pm clear --user %uid% %pkg_name%"
rem uninstall app by app package name
adb shell "pm uninstall --user %uid% %pkg_name%"
timeout /t 2 /nobreak >nul
)
)
rem Next command will return all the android user-data stored in /sdcard
rem partition of the connected Android device.
set "int_sdcard=/storage/emulated"
for /F "skip=1" "tokens=1,9 delims= " %%a in ('adb shell "ls -l %int_sdcard%/%uid%"') do (
set "dir_flag=%%a" & set "dir_name=%%b"
if not "?%dir_flag%"=="?"" (
echo %dir_flag% | findstr /C:"d" >nul
if %errorlevel% equ 0 (
set "data_fldr=%int_sdcard%/%uid%/%dir_name%"
rem backup the folder to pc
adb exec-out "tar -c %data_fldr%" > "%pc_bkup_fldr%\%dir_name%.tar"
rem delete contents of Android folder
adb shell "rm -f %data_fldr%/*"
timeout /t 2 /nobreak >nul
)
)
)
rem Next command reboots Android thus changes made take effect
adb reboot
:end
endlocal & @echo on
exit
DL: https://www.mediafire.com/file/b2qkflgiqhcni8i/my-factory-reset.bat/file
monica lewinsky said:
Is it possible to do a factory reset without data loss?
Click to expand...
Click to collapse
No
mah dude is confused factory reset is basically wiping your data partition
ineedroot69 said:
mah dude is confused factory reset is basically wiping your data partition
Click to expand...
Click to collapse
ROFL
jwoegerbauer said:
To uninstall all apps installed for Android's actual user ( default user 0 ) in one go and also backup actual user's data you can run a Windows CMD script what looks like this draft:
Code:
@echo off & setlocal
set "pc_bkup_fldr=C:\ANDROID-USER-DATA-BKUP"
rem add timestamp in ISO 8601 format to backup folder
for /F "tokens=2 delims==" %%a in ('wmic os get localdatetime /VALUE 2^>NUL') do ( set "datetime=%%a" )
if not "?%datetime%"=="?" (
for /F "tokens=1 delims=." %%a in ("%datetime%") do ( set "retval=%%a" )
if not "?%retval%"=="?" (
set yyyy=%retval:~0,4%
set mm=%retval:~4,2%
set dd=%retval:~6,2%
set "pc_bkup_fldr=%pc_bkup_fldr%-%yyyy%-%mm%-%dd%"
)
)
for /F "skip=1" "tokens=*" %%a in ('adb devices 2^>nul') do ( set "retval=%%a" )
if "?%retval%"=="?" ( goto :end )
mkdir "%pc_bkup_fldr%" 2>nul >nul
rem retrieve user id
for /F %%a in ('adb shell "am get-current-user"') do ( set "uid=%%a" )
rem Below command will return all the android user-app packages installed
rem on the connected Android device.
for /F "tokens=2 delims=:" %%a in ('adb shell "pm list packages --user %uid% -3"') do (
set "pkg_name=%%a"
if not "?%pkg_name%"=="?"
rem clear all application data (including application cache)
adb shell "pm clear --user %uid% %pkg_name%"
rem uninstall app by app package name
adb shell "pm uninstall --user %uid% %pkg_name%"
timeout /t 2 /nobreak >nul
)
)
rem Next command will return all the android user-data stored in /sdcard
rem partition of the connected Android device.
set "int_sdcard=/storage/emulated"
for /F "skip=1" "tokens=1,9 delims= " %%a in ('adb shell "ls -l %int_sdcard%/%uid%"') do (
set "dir_flag=%%a" & set "dir_name=%%b"
if not "?%dir_flag%"=="?"" (
echo %dir_flag% | findstr /C:"d" >nul
if %errorlevel% equ 0 (
set "data_fldr=%int_sdcard%/%uid%/%dir_name%"
rem backup the folder to pc
adb exec-out "tar -c %data_fldr%" > "%pc_bkup_fldr%\%dir_name%.tar"
rem delete contents of Android folder
adb shell "rm -f %data_fldr%/*"
timeout /t 2 /nobreak >nul
)
)
)
rem Next command reboots Android thus changes made take effect
adb reboot
:end
endlocal & @echo on
exit
DL: https://www.mediafire.com/file/b2qkflgiqhcni8i/my-factory-reset.bat/file
Click to expand...
Click to collapse
thanks for this. it's exactly i was looking for.

program to move apps and data

Is there a computer program that removes apps and data from one phone and reinstalls them onto another phone easier than trying to do it all "by hand", one app at a time?
You can achieve this by writing a Windows batch script that makes use of ADB commands adb backup and adb restore.
jwoegerbauer said:
You can achieve this by writing a Windows batch script that makes use of ADB commands adb backup and adb restore.
Click to expand...
Click to collapse
I appreciate the suggestion but is there any other way? I know not what a Windows batch script is or how to go about making one.
Fot the readers who know what a Windows batch script is, here an example that does the job
Code:
@echo off & setlocal
echo Unplug USB-connection between Android to get backed up and PC
echo When done press any key to continue ...
pause >nul
echo Connect Android with PC via USB
echo When done press any key to continue ...
pause >nul
adb devices
set /A cnt_pkg=0
for /F "tokens=2 delims=:" %%a in ('adb shell "pm list packages -3"') do (
set "pkg=%%a"
if NOT "?%pkg%"=="?" (
for /F "tokens=*" %%f in ('adb shell "pm dump %pkg% | grep 'ALLOW_BACKUP'"') do ( set "flags=%%f" )
if NOT "?%flags%"=="?" (
set /A cnt_pkg+=1
adb backup -f %USER%\%pkg%.backup -apk %pkg%
)
)
)
echo %cnt_pkg% user apps backed up
if %cnt_pkg% equ 0 ( goto :done )
echo Unplug USB-connection
echo When done press any key continue ...
pause >nul
echo Connect Android where apps should get restored to with PC via USB
echo When done press any key to continue ...
pause >nul
adb devices
set /A cnt_pkg=0
for /F "tokens=*" %%a in ('dir %USER%\*.backup /B') do (
set "bkup=%%a"
if NOT "?%bkup%"=="?" (
set /A cnt_pkg+=1
adb restore %USER%\%bkup%
)
)
echo %cnt_pkg% user apps restored
echo Press any key to continue ...
pause >nul
:done
endlocal & @echo on & exit

Categories

Resources