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.
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
Last edited: