Launch a script as root through ADB

后端 未结 6 1039
眼角桃花
眼角桃花 2020-12-02 15:57

I have created a script to mount partitions and do some stuff in my Android system. I saved the script as install.sh in the /bin folder of Android.

I want to call th

6条回答
  •  执念已碎
    2020-12-02 16:41

    This works for me:

    Create myscript.bat and put into it (note the single quotes around the commands to be executed in superuser mode):

    adb shell "su -c 'command1; command2; command3'"
    

    then run myscript.bat from a DOS shell.

    Note: it doesn't appear that the the DOS line continuation character (^) works in this situation. In other words, the following doesn't work for me:

    adb shell "su -c '^
    command1; ^
    command2; ^
    command3'"
    

    This results in "Syntax error: Unterminated quoted string"

提交回复
热议问题