Running multiple adb shell commands in batch file

2019-09-02 21:12发布

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"

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"

Because it says "su: su successfully su: exec failed for mount -o rw,remount /system Error:No such file or directory"

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" 

but with no luck.

How could I run a batch script which would update multiple rooted devices, so that I could just change IP? Ty in advance!

1条回答
爷的心禁止访问
2楼-- · 2019-09-02 21:28

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
)

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.

Alternatively you could put IPs into text file and read them with FOR /F.

查看更多
登录 后发表回答