bash adb 命令的批处理脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39948451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 15:17:21  来源:igfitidea点击:

Batch script for adb commands

androidbashshellbatch-fileadb

提问by Prashant Mishra

i am writing batch script for executing adb commands but while executing "SU" commands only the first commands runs "adb shell" and stops as the script is typing all the commands very fast and not waiting for previous command to run completely so that next command can be entered into the shell window that is "su" example of code is below

我正在编写用于执行 adb 命令的批处理脚本,但是在执行“SU”命令时,只有第一个命令运行“adb shell”并停止,因为脚本非常快速地键入所有命令,而不是等待上一个命令完全运行,以便下一个命令可以进入shell窗口,即“su”代码示例如下

:lckscreen
 adb shell
 su
 rm /data/system/gesture.key
 rm /data/system/*.key
 exit
 exit
 pause
 goto menu4

i also tried

我也试过

adb shell & su 

but still same Result

但结果还是一样

shell@Samsung_s4:/ $

shell@Samsung_s4:/ $

please help

请帮忙

回答by Jiaping Zhu

Please try

请尝试

adb shell "su -c 'rm /data/system/gesture.key'"
adb shell "su -c 'rm /data/system/*.key'"

and see the question in How to use su command over adb shell?

并查看如何在 adb shell 上使用 su 命令中的问题

回答by RAZERZ

You will have to create a separate .txt file containing all the shell commands, in example:

您必须创建一个单独的 .txt 文件,其中包含所有 shell 命令,例如:

su mount -o remount,rw /system mv /system/build.prop /sdcard

su mount -o remount,rw /system mv /system/build.prop /sdcard

Make sure to have put an "enter" at the bottom to execute the last command. Now, in the bat file, where you'd normally put adb shell etc. Put adb shell > nameofyourtxt.txt.

确保在底部放置一个“输入”以执行最后一个命令。现在,在 bat 文件中,您通常会在其中放置 adb shell 等。放置 adb shell > nameofyourtxt.txt。

If the only command you want to execute is "su", you can do adb shell su.

如果您要执行的唯一命令是“su”,则可以执行 adb shell su。