在批处理文件中运行多个adb shell命令 [英] Running multiple adb shell commands in batch file
问题描述
我正在制作一个批处理文件,它将对N个设备执行此操作 挂载-o rw,重新挂载/system 并将.jar文件发送到根设备上的/system/framework/ 目前我有类似的东西
I am making a batch file which would do this for N devices mount -o rw, remount /system and send .jar file to /system/framework/ on a rooted devices Currently I have something like
adb kill-server
adb start-server
adb disconnect
ECHO "Connecting"
adb connect 192.168.4.17
adb connect 192.168.4.17
adb connect 192.168.4.17
adb connect 192.168.4.17
ECHO "Connected"
adb shell su -c "mount -o rw,remount /system"
ECHO "Mounting /system sucessfully, copying.jar"
timeout 5
adb push android.policy.jar /system/framework/
ECHO "Restarting device!"
timeout 5
adb reboot
ECHO "DONE"
然后我将在N个批处理文件中复制这行,例如N次,然后更改IP. 问题是我无法运行
And then I would just copy this lines like N amount of times in 1 batch file and just change IP. The problem is that I cannot run
"adb shell su -c "mount -o rw,remount /system"
因为它说 "su:su成功 su:挂载-o rw的exec失败,重新挂载/system错误:没有这样的文件或目录"
Because it says "su: su successfully su: exec failed for mount -o rw,remount /system Error:No such file or directory"
如果我尝试在adb shell中运行多个命令的任何其他情况,它只会破坏批处理文件,并且不起作用,我也尝试过
If I try any other case of running multiple commands in adb shell it just breaks batch file and it doesn't work, I've also tried
adb shell "su & mount -o rw,remount /system"
但没有运气.
我如何运行批处理脚本来更新多个植根设备,以便仅更改IP? 提前输入!
How could I run a batch script which would update multiple rooted devices, so that I could just change IP? Ty in advance!
推荐答案
首先从一个批处理开始,该批处理将基于IP更新单个android设备,而不会出现问题.现在,看来mount
存在一些问题.之后,添加FOR
,它将从批处理命令行参数中读取IP.
First start with a batch that will update single android device based on IP without problems. Right now it seems there are some issues with mount
. After this add FOR
that will read IPs from the batch command line parameters.
@echo off
for %%a in (%*) do (
echo updating ip %%a
// YOUR BATCH GOES HERE
)
像这样运行:update.bat 192.168.4.1 192.168.4.2 192.168.4.3
.
请注意,您的设备将按顺序更新.
Run like this: update.bat 192.168.4.1 192.168.4.2 192.168.4.3
.
Note that your devices will be updated sequentially.
或者,您可以将IP放入文本文件中,然后使用FOR /F
读取它们.
Alternatively you could put IPs into text file and read them with FOR /F
.
这篇关于在批处理文件中运行多个adb shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!