bat脚本动态匹配adb devices返回的设备ID
在windows环境下新建一个bat脚本,填入以下内容
@echo off
echo send command: adb devices
adb devices
for /f %%i in ('adb devices') do (set s=%%i)
echo current device is %s%
pause
打印结果如下:
send command: adb devices
List of devices attached
AE6PWS49NFMB798H device
current device is AE6PWS49NFMB798H
请按任意键继续. . .
其中%s%
的值即为当前连接设备的ID(注:如果当前连接多台设备,则只会匹配最后一个设备的ID)