-
-
Save thebagchi/df29ae862fc1c296dec2 to your computer and use it in GitHub Desktop.
:: Inspired by Linux version of the same https://gist.github.com/christopherperry/3208109 | |
@echo off | |
SET ARGUMENTS=%~1 | |
if "%ARGUMENTS%" == "" ( | |
GOTO EOF | |
) | |
SET "ARGUMENTS=%ARGUMENTS:""="%" | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
:: INSTALL ON ALL ATTACHED DEVICES :: | |
FOR /F "tokens=1,2 skip=1" %%A IN ('adb devices') DO ( | |
SET IS_DEV=%%B | |
if "!IS_DEV!" == "device" ( | |
SET SERIAL=%%A | |
echo "adb -s !SERIAL! %ARGUMENTS%" | |
call adb -s !SERIAL! %ARGUMENTS% | |
) | |
) | |
ENDLOCAL | |
:EOF |
My Requirement:
- Need to install/uninstall apk in multiple devices
- Devices list will be vary to every time.
- How to install the apk in multiple devices in all the time without giving any device id manually
- Need automation script for this.
Please confirm below script is good one to install apk in multiple devices on windows machine!!
Also, please share the steps in detailed manner to run this.
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!
)
)
)
)
Also need instructions for how to save this BAT file?
I realize this is a bit old, but I am seeing issues here. Maybe I am missing something.
'adb devices' is returning a list of devices, but when I call this batch file nothing is seen. I am even trying to echo out IS_DEV and nothing is there. Digging in deeper 'adb devices > dev.txt' and dev.txt is empty.
Please check
- device is connected
- developer option enabled
- usb debugging on
- windows driver is installed.
I am looking forward to working with this script thank you.