I am looking for a solution to install all the apks in a folder on all the connected devices using Windows. I have looked everywhere and I can only find Bash solution.
here is the best bash I came across:
via this website http://engineering.meetme.com/2014/07/quick-tip-how-to-install-or-uninstall-apks-on-multiple-android-devices-with-just-one-command/
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
adb devices | while read line
do
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
device=`echo $line | awk '{print $1}'`
echo "adb -s $device $@ ..."
adb -s $device $@
fi
done
Now I wonder how to convert this into bat file ? Does anyone know how to do such thing please......
I can do this manually as: I run adb devices, then copy all the ids and replace in code below
ECHO Running Bat script
@ECHO OFF
:: comment
adb -s <DEVICE_ID> install MyApk.apk
adb -s <DEVICE_ID> install MyApk2.apk
adb -s <DEVICE_ID> install MyApk3.apk
But I need to automate this process.
I need to learn how to get all the connected devices_id as the bash code above. then get all the .apk files in the folder (where this bat file will be). Then run the install...
Really Appreciate if anyone knows how to help. Thanks.
Finally, managed to implement it correctly (install all apks from current folder to all connected devices):
echo off
setlocal EnableDelayedExpansion
for /f "tokens=*" %%f in ('C:\android\sdk\platform-tools\adb.exe devices') do (
for /r %%p in (*.apk) do (
set devicestr=%%f
set apk=%%p
if "!devicestr!"=="!devicestr:List=!" (
for /f "tokens=1" %%d in ("!devicestr!") do (
set deviceid=%%d
echo !deviceid!
echo !apk!
C:\android\sdk\platform-tools\adb.exe -s !deviceid! install !apk!
)
)
)
)
this line removes "List of connected devices":
if "!devicestr!"=="!devicestr:List=!" (
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With