1、mod.bat源码
使用bat文件修改多个android终端的文件重启
::如果当前是老版本,a设置为0;如果是新版本,设置为1
@echo off
set /a n=0
setlocal enabledelayedexpansion
set a=0
:loop
adb connect 192.168.20.237
ping -n 1 -w 3000 1.1.1.2>nul
if %a% equ 0 (
echo “a=”%a%
adb -s 192.168.20.237:5555 shell rm /etc/mr/zip
adb -s 192.168.20.237:5555 push a.zip /etc/mr
adb -s 192.168.20.237:5555 shell sync
set a=1
) else (
echo “a=”%a%
adb -s 192.168.20.237:5555 shell rm /etc/mr/zip
adb -s 192.168.20.237:5555 push b.zip /etc/mr
adb -s 192.168.20.237:5555 shell sync
set a=0
)
ping -n 1 -w 3000 1.1.1.2>nul
start reboot.bat
::重启之后,等300秒
ping -n 1 -w 300000 1.1.1.2>nul
set /a n+=1
echo “looptimes:”
echo !n!
::打印执行次数
adb disconnect 192.168.20.237
ping -n 1 -w 3000 1.1.1.2>nul
goto loop
======================================================================================
2、reboot.bat源码
adb -s 192.168.20.237:5555 shell reboot
ping -n 1 -w 20000 1.1.1.2>nul
exit
遇到的问题:
1、使用adb reboot命令时出错:error: more than one device/emulator
提示adb链接了不止一个设备,这样就不知道对哪个设备进行重启。
查询adb 设备,确认是否有多个设备
adb devices 查出来有两台设备。
解决办法:指定device来执行adb shell
adb -s 192.168.20.242:5555 shell reboot
2、脚本mod.bat会调用reboot.bat,所以每次调用都会新开一个窗口执行reboot.bat。这样循环跑一天就会有N次*N个设备多窗口。脚本添加命令如下。
ping -n 1 -w 20000 1.1.1.2>nul ::间隔20s后,exit退出该窗口。-w (单位:ms)
exit