ADB

ADB Commands for Multiple Devices: Copy-Paste Scripts

Run ADB on every connected Android phone at once: install APKs, push files, open apps, tap, swipe and screenshot. CMD and PowerShell scripts.

Updated Oct 25, 20268 min readBy the RovaFlow team

ADB (Android Debug Bridge) is Google's official command-line tool for talking to Android phones. It can install apps, move files, open apps, tap the screen and much more, but it sends each command to one device. This guide gives you copy-paste Windows scripts that run any ADB command on every connected phone, plus the commands that are most useful when you manage many devices.

Before you start: every phone needs USB debugging on and your PC authorised. See steps 1 and 2 of How to control multiple Android phones from one PC.

Target one device

adb devices -l                       # list serials with model names
adb -s R58M42ABCDE shell getprop ro.product.model

Without -s, ADB fails with more than one device/emulator. To avoid typing -s repeatedly in a session, set an environment variable: set ANDROID_SERIAL=R58M42ABCDE (CMD) or $env:ANDROID_SERIAL="R58M42ABCDE" (PowerShell).

Run a command on every phone

CMD batch template (all.bat)

@echo off
rem Usage: all.bat shell getprop ro.product.model
for /f "skip=1 tokens=1,2" %%a in ('adb devices') do (
  if "%%b"=="device" (
    echo === %%a ===
    adb -s %%a %*
  )
)

Anything you type after all.bat is run on each phone, for example all.bat reboot or all.bat install -r app.apk.

PowerShell template

function Invoke-AdbAll {
    param([Parameter(ValueFromRemainingArguments)] $AdbArgs)
    adb devices | Select-String "\tdevice$" | ForEach-Object {
        $serial = ($_ -split "\t")[0]
        Write-Host "=== $serial ==="
        adb -s $serial @AdbArgs
    }
}
# Example: Invoke-AdbAll shell getprop ro.product.model

Run on all phones in parallel (PowerShell 7)

$serials = adb devices | Select-String "\tdevice$" | ForEach-Object { ($_ -split "\t")[0] }
$serials | ForEach-Object -Parallel {
    adb -s $_ install -r "C:\builds\app.apk"
} -ThrottleLimit 8

Parallel runs are much faster for installs and file copies. Keep -ThrottleLimit moderate so USB bandwidth isn't saturated.

Most useful commands for many phones

Each command below is shown for one phone; put it in a template above to run it on every phone.

TaskCommand
Install or update an appadb -s SERIAL install -r app.apk
Uninstall an appadb -s SERIAL uninstall com.example.app
Open an appadb -s SERIAL shell monkey -p com.example.app -c android.intent.category.LAUNCHER 1
Close an appadb -s SERIAL shell am force-stop com.example.app
Copy a file to the phoneadb -s SERIAL push video.mp4 /sdcard/Download/
Copy a file from the phoneadb -s SERIAL pull /sdcard/Download/report.txt .
Tap at x,yadb -s SERIAL shell input tap 540 1600
Swipe upadb -s SERIAL shell input swipe 540 1600 540 600 300
Type textadb -s SERIAL shell input text "hello%sworld" (%s = space)
Home / Back / Wakeadb -s SERIAL shell input keyevent KEYCODE_HOME (or KEYCODE_BACK, KEYCODE_WAKEUP)
Keep awake while chargingadb -s SERIAL shell svc power stayon usb
Battery level and temperatureadb -s SERIAL shell dumpsys battery
Screen resolutionadb -s SERIAL shell wm size
Rebootadb -s SERIAL reboot

Screenshot every phone

@echo off
for /f "skip=1 tokens=1,2" %%a in ('adb devices') do (
  if "%%b"=="device" (
    adb -s %%a shell screencap -p /sdcard/rf_shot.png
    adb -s %%a pull /sdcard/rf_shot.png "shot_%%a.png"
  )
)

Saving on the phone and then pulling the file avoids a PowerShell quirk that corrupts binary output redirected with >.

Common pitfalls

  • Different screen sizes: input tap uses pixels, so check each model's resolution with wm size and keep separate coordinates per model.
  • Locked screens: taps don't reach apps behind the lock screen. Wake and unlock first, and use "Stay awake" in Developer options.
  • Xiaomi and some brands: input commands need "USB debugging (Security settings)" turned on.
  • Slow loops: a 100 MB APK on 30 phones one after another takes a while. Use the parallel PowerShell version.
  • No visibility: scripts run blind. Pair them with scrcpy windows (scrcpy for multiple devices) or a screen wall to see what happened.

Skip the scripts

RovaFlow puts these actions behind buttons: mass APK install, file manager, open/close apps on every phone, one-to-many taps and no-code workflows. You see every screen live while it runs. Windows, real devices, one-time price.

See RovaFlow pricing

FAQ

How do I run an ADB command on all connected devices?

ADB itself sends a command to one device at a time. Loop over the serial numbers from adb devices and run the command with -s SERIAL for each phone, as in the CMD and PowerShell scripts in this guide.

What does "more than one device/emulator" mean?

ADB doesn't know which phone you mean. Add -s SERIAL to the command, or set the ANDROID_SERIAL environment variable to the phone you want.

Can ADB commands run on all phones at the same time?

Yes. A normal loop runs phone by phone. In PowerShell 7 you can use ForEach-Object -Parallel to run the command on several phones at once, which is much faster for installs and file transfers.

Will the same tap coordinates work on every phone?

Only if the phones have the same screen resolution and layout. adb shell input tap uses pixel coordinates, so mixed models need different coordinates per model.

Related guides

Home Features Pricing Sign In
Chat with us