adb 通过 wifi 连接的批处理脚本
batch script for adb connect over wifi
我正在尝试编写一个批处理脚本来自动执行某些任务,并根据上一个命令的响应或输出生态灭绝下一个命令或输出。
adb connect %IP%:5555
if errorlevel 1 (
echo Not Able To connect With Provided Ip Address
goto getip
) else (
echo Connected Over Wifi
goto menu2
)
但它不起作用,因为我认为在每种情况下错误级别都是 0
由于设备连接成功与否输出相同 "Connected Over wifi".
一般当我们输入命令adb connect <IP>
时,输出是
1)连接成功输出为
connected to 192.168.10.13:5555
2) 当 android 设备在 wifi lan 中并输入 "ip" 是正确的但“5555”端口未打开时输出为
unable to connect to 192.168.10.13:5555: cannot connect to 192.168.10.13:5555: No connection could be made because the target machine actively refused it. (10061)
3)当笔记本电脑 wifi 关闭时
unable to connect to 192.168.10.13:5555: cannot connect to 192.168.10.13:5555: A socket operation was attempted to an unreachable host. (10065)
4) 当 android 的 wifi 关闭时
unable to connect to 192.168.10.2:5555: cannot connect to 192.168.10.2:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
我只想定义两种情况"connection Successful" or "Not Successful"
根据 adb over wifi 连接设置,我应该如何自动执行任务。请帮忙
您可以将 adb 的输出通过管道传递给 FIND 并搜索指示成功或失败的标志性标记,例如 "unable to" 或 "connected to"。
@echo off & setlocal
set IP=192.168.10.13:5555
adb connect %IP% | find /i "connected to" >nul
if errorlevel 1 (
echo Not successful
) else (
echo Successful
)
我正在尝试编写一个批处理脚本来自动执行某些任务,并根据上一个命令的响应或输出生态灭绝下一个命令或输出。
adb connect %IP%:5555
if errorlevel 1 (
echo Not Able To connect With Provided Ip Address
goto getip
) else (
echo Connected Over Wifi
goto menu2
)
但它不起作用,因为我认为在每种情况下错误级别都是 0 由于设备连接成功与否输出相同 "Connected Over wifi".
一般当我们输入命令adb connect <IP>
时,输出是
1)连接成功输出为
connected to 192.168.10.13:5555
2) 当 android 设备在 wifi lan 中并输入 "ip" 是正确的但“5555”端口未打开时输出为
unable to connect to 192.168.10.13:5555: cannot connect to 192.168.10.13:5555: No connection could be made because the target machine actively refused it. (10061)
3)当笔记本电脑 wifi 关闭时
unable to connect to 192.168.10.13:5555: cannot connect to 192.168.10.13:5555: A socket operation was attempted to an unreachable host. (10065)
4) 当 android 的 wifi 关闭时
unable to connect to 192.168.10.2:5555: cannot connect to 192.168.10.2:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)
我只想定义两种情况"connection Successful" or "Not Successful"
根据 adb over wifi 连接设置,我应该如何自动执行任务。请帮忙
您可以将 adb 的输出通过管道传递给 FIND 并搜索指示成功或失败的标志性标记,例如 "unable to" 或 "connected to"。
@echo off & setlocal
set IP=192.168.10.13:5555
adb connect %IP% | find /i "connected to" >nul
if errorlevel 1 (
echo Not successful
) else (
echo Successful
)