Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if adb device connected condition

How can I check adb device is connected in batch files? I wrote "adb devices" in the batch file, but I want it as a condition so the app working smoothly and automatically So if the user is not connected his device print no device and exit the app, Otherwise resume the app.

like image 873
3llomi Avatar asked Jul 11 '26 20:07

3llomi


1 Answers

Pipe the output to find and analyse the errorlevel:

adb devices -l | find "device product:" >nul
if errorlevel 1 (
    echo No connected devices
) else (
    echo Found!
    ..............
)
like image 69
wOxxOm Avatar answered Jul 13 '26 10:07

wOxxOm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!