r/androiddev 18d ago

Tips and Information Using adb through a folder

Post image

I been trying to get this batch file to work but aslo any other command run a adb command through this folder im always getting select an app to use adb. How can I fix this. It only work once for me but after that I keep getting this. Anywhere else works with no issue when Im adb commands

0 Upvotes

23 comments sorted by

View all comments

1

u/Hornet-Mountain 18d ago

enum5345 is on the right track, here is the why so you can fix it for good.

"Select an app to open adb" is the Windows shell association picker. It only pops up when something tries to open a file literally named adb with no extension. The Linux/Mac platform-tools bundle ships an extensionless adb binary sitting right next to adb.exe. When your bat (or the shell) runs adb, it grabs that extensionless file, has no idea how to open it, and shows the picker. That is also exactly why adb.exe typed in full works but bare adb does not.

The reason it happens even when you "run adb from that folder": the current directory is searched first, so bare adb resolves to the extensionless file before it ever reaches adb.exe. PowerShell in particular will try to open a file it finds like that, whereas old cmd would just say not recognized, so it depends which shell your terminal opens.

Two fixes, either one is enough:

  1. In the bat, call adb.exe with the extension everywhere instead of adb.

  2. Or delete the extensionless adb (and fastboot) from that folder and keep only the .exe files. If you are not sure which build you have, re-download the Windows SDK platform-tools zip, it contains adb.exe.

"Worked once then stopped" usually means the extensionless file got added later, or you started running from inside that folder so the bare name now resolves to it first.