Skip to content

Instantly share code, notes, and snippets.

@IdrisN
Created October 9, 2018 10:18
Show Gist options
  • Select an option

  • Save IdrisN/80b7c281f735cbdb17c841b3f3875b2d to your computer and use it in GitHub Desktop.

Select an option

Save IdrisN/80b7c281f735cbdb17c841b3f3875b2d to your computer and use it in GitHub Desktop.
Batch script to enable wireless adb with just one command
FOR /F "tokens=9 delims= " %%a in ('adb shell ip route') do (
set ip=%%a
)
adb tcpip 5555
set ipwithport=%ip%:5555
adb connect %ipwithport%
@IdrisN
Copy link
Author

IdrisN commented Oct 9, 2018

CutIt

Wireless ADB with one command

The usual procedure to set up a wireless adb connection has to many steps in my opinion:

  1. Set up an tcpip port with adb tcpip 5555
  2. Look up the IP address of your android device
  3. enable an wireless connection with adb connect <ip>:5555

See? Takes way too much time. Especially the IP look-up.

The provides batch script reduces the procedure to the following

  1. execute cutit

Done!

Remarks

  1. Both your computer and mobile device have to be in the same wifi network
  2. For maximum convenience add the batch script to your path variable

@TripleEYE
Copy link

Hello, and thank you.
I have three questions (sorry if I'm asking about obvious things, I'm learning this on my own):

  1. Does this command find out the Android's IP on its own somehow? (the for loop contents confuse me here)
  2. How does it know?
  3. Also, am I supposed to replace 'adb shell ip route' with the following?
    C:\Users\MyUser\WhereMyAdbFilesAreLocated\platform-tools\

Thank you for sharing your code and for any patient answers you are able to provide.

P.S.
I also stumbled upon an article you may or may not be interested in, related to the topic of your code.
Disclaimer: The article is not mine and I have no relation to its author; But I found his method to be quite comprehensive (if perhaps unnecessarily convoluted for some), and encompassing.
If you're interested (I hope I'm not braking any rules by posting an external link here):
https://copyprogramming.com/howto/batch-script-for-adb-connect-over-wifi

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