0-TEST-CONNECT.BAT 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. @echo off
  2. chcp 65001 >nul
  3. echo ========================================
  4. echo Test ADB Connection
  5. echo ========================================
  6. echo.
  7. echo Please enter the last two digits of the IP address:
  8. set /p IP_LAST_TWO="Last two digits (e.g., 0.15): "
  9. if "%IP_LAST_TWO%"=="" (
  10. echo Error: IP address cannot be empty
  11. pause
  12. exit /b 1
  13. )
  14. set DEVICE_IP=192.168.%IP_LAST_TWO%
  15. set DEVICE_PORT=5555
  16. set DEVICE_ADDRESS=%DEVICE_IP%:%DEVICE_PORT%
  17. echo.
  18. echo Connecting to %DEVICE_ADDRESS%...
  19. echo.
  20. echo [1/5] Check if ADB is available...
  21. adb version >nul 2>&1
  22. if errorlevel 1 (
  23. echo Error: ADB not installed or not in PATH
  24. echo Please ensure Android SDK Platform Tools is installed
  25. pause
  26. exit /b 1
  27. )
  28. echo ADB is available
  29. echo.
  30. echo [2/5] Test network connectivity (ping %DEVICE_IP%)...
  31. ping -n 2 %DEVICE_IP% >nul 2>&1
  32. if errorlevel 1 (
  33. echo Cannot ping %DEVICE_IP%
  34. echo Possible reasons: Phone and computer not on same network, or phone is off
  35. echo.
  36. ) else (
  37. echo Network connectivity OK
  38. echo.
  39. )
  40. echo [3/5] Check if port %DEVICE_PORT% is open...
  41. powershell -Command "Test-NetConnection -ComputerName %DEVICE_IP% -Port %DEVICE_PORT% -InformationLevel Quiet" >nul 2>&1
  42. if errorlevel 1 (
  43. echo Port %DEVICE_PORT% may not be open or blocked by firewall
  44. echo.
  45. ) else (
  46. echo Port %DEVICE_PORT% is accessible
  47. echo.
  48. )
  49. echo [4/5] Disconnect old connection (if any)...
  50. adb disconnect %DEVICE_ADDRESS% >nul 2>&1
  51. timeout /t 1 /nobreak >nul
  52. echo Attempting to connect %DEVICE_ADDRESS%...
  53. adb connect %DEVICE_ADDRESS%
  54. set CONNECT_RESULT=%ERRORLEVEL%
  55. echo.
  56. if %CONNECT_RESULT% equ 0 (
  57. echo Connection command completed
  58. echo.
  59. timeout /t 2 /nobreak >nul
  60. ) else (
  61. echo.
  62. echo Connection failed (Error code: %CONNECT_RESULT%)
  63. echo.
  64. echo ========================================
  65. echo Troubleshooting Steps:
  66. echo ========================================
  67. echo 1. Enable "Developer Options" on phone
  68. echo - Settings ^> About phone ^> Tap "Build number" 7 times
  69. echo.
  70. echo 2. Enable "USB debugging"
  71. echo - Settings ^> Developer options ^> USB debugging
  72. echo.
  73. echo 3. Enable "Wireless debugging" or "Network ADB debugging"
  74. echo - Settings ^> Developer options ^> Wireless debugging
  75. echo - Or: Settings ^> Developer options ^> Network ADB debugging
  76. echo - Confirm port is %DEVICE_PORT%
  77. echo.
  78. echo 4. If phone doesn't have "Wireless debugging" option, try:
  79. echo a) Connect phone to computer via USB
  80. echo b) Run: adb tcpip 5555
  81. echo c) Unplug USB, then run this script again
  82. echo.
  83. echo 5. Check if phone and computer are on same Wi-Fi network
  84. echo.
  85. echo 6. Disable phone firewall or allow ADB through firewall
  86. echo.
  87. )
  88. echo [5/5] Check device list...
  89. echo.
  90. adb devices
  91. echo.
  92. echo ========================================
  93. echo Test completed
  94. echo ========================================
  95. pause