Skip to content

Instantly share code, notes, and snippets.

@am3n
Last active November 15, 2023 15:32
Show Gist options
  • Save am3n/589e9a1f9dc588f7b6aabbd8fc0baf64 to your computer and use it in GitHub Desktop.
Save am3n/589e9a1f9dc588f7b6aabbd8fc0baf64 to your computer and use it in GitHub Desktop.
Wi-Fi ADB batch script
@setlocal enableextensions enabledelayedexpansion
@echo off
for /F "tokens=*" %%A in ('adb devices') do (
set str1=%%A
if "x!str1:List=!"=="x!str1!" (
if "x!str1::5555=!"=="x!str1!" (
set id=!str1:device=!
adb -s !id! tcpip 5555
timeout /T 2 /NOBREAK > nul
for /F "tokens=*" %%A in ('adb -s !id! shell "ip addr show wlan0 | grep -e wlan0$ | cut -d\" \" -f 6 | cut -d/ -f 1"') do (
set ip=%%A
echo !ip! !id!
adb -s !id! connect !ip!
)
)
)
)
@endlocal
@am3n
Copy link
Author

am3n commented Nov 15, 2023

By running this script, the remote adb connection will be established with all the devices that are connected via USB and also connected to the local network.
You can put this script in sdk\platform-tools\ so that you can easily run it through the terminal.

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