Themes / Apps / Mods BulkInstall & BulkPull batch scripts for Windows (For use with Watch/Phone)

Search This thread

73sydney

Senior Member
Okay, so as i have often had to reset the watch during testing this and that, and since i have a few apks that arent on the Google Play store, i wanted a quick easy way to backup the 3rd party apks on my watch, and to also have a quick easy way to bulk install them after reset. They both handle single and split apks. While written for the watch , you can of course use them for any device that you can adb connect to...be aware that devices other than the watch will have a LOT more 3rd party packages on it, so be prepared for the runtime

The result are the attached scripts, tested in Windows 10 in (default Powershell) terminal

Thought i'd share them in case they were useful to anyone else



bulkpull.bat:

Does what it says on the tin, bulk pulls all 3rd party apks from the Watch (or other abd connectable device)

Usage:

1) Put bulkpull.bat in folder where you would like to backup packages (i would suggest naming it after the device....i use Watch)
2) Open bulkpull.bat in an editor and edit the following line at top:

SET ADB_PATH=c:\platform-tools

Default path to look for adb.exe is c:\platform-tools. Adjust to your location of adb.exe OR if platform-tools/adb is in your PATH, comment out the line by adding an rem to the front of the line, as follows:

rem SET ADB_PATH=c:\platform-tools

save the bulkpull.bat file

3) Open a terminal at the location of bulkpull.bat
4) Run .\bulkpull.bat

Method:

The script will ask you to supply an IP address if you are connecting to a device (like the Watch) via Wifi. If you are not, and its cabled, just press ENTER.
The script will pull a list of 3rd party packages into a local myapps.txt file in script folder (via the line: !ADB_PATH!\adb shell pm list packages -3 > myapps.txt, where -3 is used to signify 3rd party apps).
The script will then loop through each line of the file and:

1) Create a folder named after the packagename
2) Copy any apks for that package to that folder
3) Do this until all packages listed are pulled
4) Display a summary at end of script




bulkinstall.bat:

Does what it says on the tin, bulk installs all 3rd party apks stored under script folder AND subfolders to the Watch (or other abd connectable device)

Usage:

1) Put bulkinstall.bat in folder where your 3rd party apks are backed up (ideally its the one you bulkpulled to previously)
2) Open bulkinstall.bat in an editor and edit the following line at top:

SET ADB_PATH=c:\platform-tools

Default path to look for adb.exe is c:\platform-tools. Adjust to your location of adb.exe OR if platform-tools/adb is in your PATH, comment out the line by adding an rem to the front of the line, as follows:

rem SET ADB_PATH=c:\platform-tools

save the bulkinstall.bat file

3) Open a terminal at the location of bulkinstall.bat
4) Run .\bulkinstall.bat

Method:

The script will ask you to supply an IP address if you are connecting to a device (like the Watch) via Wifi. If you are not, and its cabled, just press ENTER.
The script will then loop through each apk in the main folder and subfolder file and:

1) Install any apks for the package, until no more apks remain
2) Display a summary at end of script

Notes on main folder and subfolders (why theres an extra script routine for the main folder):

Sometimes on a rare occasion i will have a single apk file for an app that is not on the Play Store, and that ive picked up since the last bulkpull (backup) and im installing it for the first time along with the bulkinstall of the previously backed up apks after a reset. I will dump the single apk(s) into the main folder where the script is, then run bulkinstall.bat, to install the new single apk(s) in the main folder, along with the previously bulkpulled apks in named folders. Once i have done this i will then run a bulkpull, and then delete the single apk(s) in the main folder, as they will now be bulkpulled and be under a properly named subfolder. I hope that makes sense. Again this is my own way of working. The main thing to remember is that whether an apk is placed in the main folder, or a nicely named subfolder, it WILL get installed.


Both files are commented (completely ruining the brevity) so you can see what and how they are doing what they do.

There are no destructive steps involved, no deletes etc.

As always, and despite the above statement of non-destructive scripting, the usual disclaimers apply, you alone are responsible for what, and how, you run scripts and programs on your PC and i am not liable if you manage to find interesting ways to abuse my work.
 

Attachments

  • bulktools.zip
    2.7 KB · Views: 57
Last edited:

73sydney

Senior Member
Nice work. There is an app that can be used that does many other things. It is called ADB AppControl.

Im aware of the app

Sometimes, most times in fact, i dont want to install an entire bloated app to do what can be done with a few lines of code.....take out all the comments and blank lines and its pretty slim

This wasnt a please suggest me an app thread, just sharing what i use - it even says that - this is how I work ("Again this is my own way of working"), not saying its how anyone else should :)
 
  • Like
Reactions: JazonX and adfree

JazonX

Senior Member
Dec 16, 2009
2,301
895
Xiaomi Mi 11 Ultra
Im aware of the app

Sometimes, most times in fact, i dont want to install an entire bloated app to do what can be done with a few lines of code.....take out all the comments and blank lines and its pretty slim

This wasnt a please suggest me an app thread, just sharing what i use - it even says that - this is how I work ("Again this is my own way of working"), not saying its how anyone else should :)


Love this idea and I truly admire it. Why another app is always a question I have.
 
  • Like
Reactions: 73sydney

73sydney

Senior Member
Love this idea and I truly admire it. Why another app is always a question I have.

Yup, in fact i bloated it in the pursuit of making it (possibly) usable by others, if you look at bulkpull.. remove all the comments, connection and user feedback code and its just this....all 20 lines of it


@echo off
setlocal enabledelayedexpansion enableextensions
SET ADB_PATH=c:\platform-tools
!ADB_PATH!\adb shell pm list packages -3 > myapps.txt
if exist myapps.txt for /F "tokens=2 delims=:" %%p in (myapps.txt) do (
set packagename=%%p
set count=0
set num=0
for /F "tokens=2 delims=: USEBACKQ" %%F IN (`!ADB_PATH!\adb shell pm path !packagename!`) do (
set apkname[!count!]=%%~F
set /a count=!count!+1
set /a num=!count!-1
)
mkdir !packagename!
for /L %%i in (0,1,!num!) do (
!ADB_PATH!\adb pull !apkname[%%i]! !packagename!
)
ping 127.0.0.1 -n 2 > nul
)
endlocal
 
Last edited:

jayjay1234

Senior Member
Jan 24, 2009
333
109
Looks like a useful tool Thanks.

Does this scrip only pull the apks or does it pull the data setting for the apks also?
 

73sydney

Senior Member
Looks like a useful tool Thanks.

Does this scrip only pull the apks or does it pull the data setting for the apks also?

It only pulls 3rd party apks (as set - you could pull ALL apks, but i just use it because i have a lot of apks from github repos or non-play websites id hate to have to go visit and re-download every reset), you need root access to pull appdata sorry...aint no root for the Watch series (yet/likely ever)...trust me if there was a way i would be backign up appdata on the thing with the amount of resets ive had to do....

if youre looking for a root non-Watch backup solution that does backup (and restore) apks and appdata, and permissions, i use and recommend Migrate (only v4 though, 5 is still too buggy to complete a working backup):


and how i use it and have for ages, years, what i call "the easy streamlined way"

 
Last edited:
  • Like
Reactions: jayjay1234

jayjay1234

Senior Member
Jan 24, 2009
333
109
It only pulls 3rd party apks (as set - you could pull ALL apks, but i just use it because i have a lot of apks from github repos or non-play websites id hate to have to go visit and re-download every reset), you need root access to pull appdata sorry...aint no root for the Watch series (yet/likely ever)...trust me if there was a way i would be backign up appdata on the thing with the amount of resets ive had to do....

if youre looking for a root non-Watch backup solution that does pull apks and appdata, and permissions, i use and recommend Migrate (only v4 though, 5 is still too buggy to complete a working backup):


and how i use it and have for ages, what i call "the easy strreamlined way"

Thanks for the info and other options!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Okay, so as i have often had to reset the watch during testing this and that, and since i have a few apks that arent on the Google Play store, i wanted a quick easy way to backup the 3rd party apks on my watch, and to also have a quick easy way to bulk install them after reset. They both handle single and split apks. While written for the watch , you can of course use them for any device that you can adb connect to...be aware that devices other than the watch will have a LOT more 3rd party packages on it, so be prepared for the runtime

    The result are the attached scripts, tested in Windows 10 in (default Powershell) terminal

    Thought i'd share them in case they were useful to anyone else



    bulkpull.bat:

    Does what it says on the tin, bulk pulls all 3rd party apks from the Watch (or other abd connectable device)

    Usage:

    1) Put bulkpull.bat in folder where you would like to backup packages (i would suggest naming it after the device....i use Watch)
    2) Open bulkpull.bat in an editor and edit the following line at top:

    SET ADB_PATH=c:\platform-tools

    Default path to look for adb.exe is c:\platform-tools. Adjust to your location of adb.exe OR if platform-tools/adb is in your PATH, comment out the line by adding an rem to the front of the line, as follows:

    rem SET ADB_PATH=c:\platform-tools

    save the bulkpull.bat file

    3) Open a terminal at the location of bulkpull.bat
    4) Run .\bulkpull.bat

    Method:

    The script will ask you to supply an IP address if you are connecting to a device (like the Watch) via Wifi. If you are not, and its cabled, just press ENTER.
    The script will pull a list of 3rd party packages into a local myapps.txt file in script folder (via the line: !ADB_PATH!\adb shell pm list packages -3 > myapps.txt, where -3 is used to signify 3rd party apps).
    The script will then loop through each line of the file and:

    1) Create a folder named after the packagename
    2) Copy any apks for that package to that folder
    3) Do this until all packages listed are pulled
    4) Display a summary at end of script




    bulkinstall.bat:

    Does what it says on the tin, bulk installs all 3rd party apks stored under script folder AND subfolders to the Watch (or other abd connectable device)

    Usage:

    1) Put bulkinstall.bat in folder where your 3rd party apks are backed up (ideally its the one you bulkpulled to previously)
    2) Open bulkinstall.bat in an editor and edit the following line at top:

    SET ADB_PATH=c:\platform-tools

    Default path to look for adb.exe is c:\platform-tools. Adjust to your location of adb.exe OR if platform-tools/adb is in your PATH, comment out the line by adding an rem to the front of the line, as follows:

    rem SET ADB_PATH=c:\platform-tools

    save the bulkinstall.bat file

    3) Open a terminal at the location of bulkinstall.bat
    4) Run .\bulkinstall.bat

    Method:

    The script will ask you to supply an IP address if you are connecting to a device (like the Watch) via Wifi. If you are not, and its cabled, just press ENTER.
    The script will then loop through each apk in the main folder and subfolder file and:

    1) Install any apks for the package, until no more apks remain
    2) Display a summary at end of script

    Notes on main folder and subfolders (why theres an extra script routine for the main folder):

    Sometimes on a rare occasion i will have a single apk file for an app that is not on the Play Store, and that ive picked up since the last bulkpull (backup) and im installing it for the first time along with the bulkinstall of the previously backed up apks after a reset. I will dump the single apk(s) into the main folder where the script is, then run bulkinstall.bat, to install the new single apk(s) in the main folder, along with the previously bulkpulled apks in named folders. Once i have done this i will then run a bulkpull, and then delete the single apk(s) in the main folder, as they will now be bulkpulled and be under a properly named subfolder. I hope that makes sense. Again this is my own way of working. The main thing to remember is that whether an apk is placed in the main folder, or a nicely named subfolder, it WILL get installed.


    Both files are commented (completely ruining the brevity) so you can see what and how they are doing what they do.

    There are no destructive steps involved, no deletes etc.

    As always, and despite the above statement of non-destructive scripting, the usual disclaimers apply, you alone are responsible for what, and how, you run scripts and programs on your PC and i am not liable if you manage to find interesting ways to abuse my work.
    2
    Nice work. There is an app that can be used that does many other things. It is called ADB AppControl.

    Im aware of the app

    Sometimes, most times in fact, i dont want to install an entire bloated app to do what can be done with a few lines of code.....take out all the comments and blank lines and its pretty slim

    This wasnt a please suggest me an app thread, just sharing what i use - it even says that - this is how I work ("Again this is my own way of working"), not saying its how anyone else should :)
    1
    Nice work. There is an app that can be used that does many other things. It is called ADB AppControl.
    1
    Im aware of the app

    Sometimes, most times in fact, i dont want to install an entire bloated app to do what can be done with a few lines of code.....take out all the comments and blank lines and its pretty slim

    This wasnt a please suggest me an app thread, just sharing what i use - it even says that - this is how I work ("Again this is my own way of working"), not saying its how anyone else should :)


    Love this idea and I truly admire it. Why another app is always a question I have.
    1
    Looks like a useful tool Thanks.

    Does this scrip only pull the apks or does it pull the data setting for the apks also?

    It only pulls 3rd party apks (as set - you could pull ALL apks, but i just use it because i have a lot of apks from github repos or non-play websites id hate to have to go visit and re-download every reset), you need root access to pull appdata sorry...aint no root for the Watch series (yet/likely ever)...trust me if there was a way i would be backign up appdata on the thing with the amount of resets ive had to do....

    if youre looking for a root non-Watch backup solution that does backup (and restore) apks and appdata, and permissions, i use and recommend Migrate (only v4 though, 5 is still too buggy to complete a working backup):


    and how i use it and have for ages, years, what i call "the easy streamlined way"