Skip to content

Instantly share code, notes, and snippets.

@smelfungus
Created June 12, 2016 10:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save smelfungus/f3cc57a8f564baf5ba88fd16c5bae85e to your computer and use it in GitHub Desktop.
Save smelfungus/f3cc57a8f564baf5ba88fd16c5bae85e to your computer and use it in GitHub Desktop.
Run ADB shell command with options on all connected devices
:: Inpired by Windows version https://gist.github.com/thebagchi/df29ae862fc1c296dec2
:: Which is inspired by Linux version of the same https://gist.github.com/christopherperry/3208109
@echo off
SET ARGUMENTS=%*
if "%ARGUMENTS%" == "" (
GOTO EOF
)
SET "ARGUMENTS=%ARGUMENTS:""="%"
SETLOCAL ENABLEDELAYEDEXPANSION
:: EXECUTE SHELL COMMAND 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! shell %ARGUMENTS%"
call adb -s !SERIAL! shell %ARGUMENTS%
)
)
ENDLOCAL
:EOF
@smelfungus
Copy link
Author

Usage example:
ADBShell+ am start -n com.package.name/com.package.name.ActivityName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment