Skip to content

Instantly share code, notes, and snippets.

@thebagchi
Forked from smelfungus/ADBShell+.bat
Created December 14, 2020 18:13
Show Gist options
  • Save thebagchi/c160d8155061ec0e9b2391c330ce2574 to your computer and use it in GitHub Desktop.
Save thebagchi/c160d8155061ec0e9b2391c330ce2574 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment