cmd窗口使用adb命令(尤其同时测多个手机)时,可用批处理(要注意的地方比较多),推荐使用简单批处理命令,结合python执行
将下面命令直接写成批处理文件,双击即可
导出文件
adb pull sdcard/FaceUnity/FUtester/
生成日志文件
adb logcat -c
adb logcat > samsungs4_zego.log
python中用adb命令机运行.bat文件操作
import re import sys import os import time print ("hello world") os.system('exportDevicesList.bat') with open ("C:/Users/Administrator/Desktop/deviceId.txt",'r',encoding='UTF-8') as f: pattern = re.compile(r' ') i = 0 for line in f: m = line.split(' ') print (m) if(len(m) >1): print (line) os.system('adb -s ' +m[0]+' uninstall com.xxx.xx' ) i=i+1 f.close() os.system('installApk.bat') #adb pull sdcard/
adb中同事安装多个apk到多个手机
@echo off&setlocal enabledelayedexpansion title Install-MultipleDevices color 0a rem +++++++++++++++++++++++++++++++++++++++++++ rem Install-MultipleDevices.bat rem By kangxinjie @2017/11/27 rem rem Version: 1.0 rem +++++++++++++++++++++++++++++++++++++++++++ rem 两个adb devices 为了减少deamon start successfully语句写入deviceId.txt中 adb devices adb devices >deviceId.txt rem 处理0台设备的情况 set count=0 type nul>temp.txt rem tonkes与delims的位置不能改变,否则会出现显示混乱 for /f "skip=1 tokens=1 delims= " %%i in (deviceId.txt) do ( echo %%i >>temp.txt set /a count+=1 ) echo 总共!count!台设备 for /f %%i in (temp.txt) do ( start "Device:%%i" cmd /k "@echo off& for /r "%cd%apkPackage" %%a in (*.apk) do ( echo APK=%%~nxa &adb -s %%i install -r %%a)" ) del temp.txt pause
下面的批处理文件:将文件名导出到文件里
DIR C:UsersAdministratorDesktop优化后cpu /B >LIST.txt