1

is there a way to run adb shell commands via windows?

I would like to run a batch script such as this

adb shell 
mount -o rw,remount /system
exit

Currently when i run the batch script it only runs the first command adb shell

2

Wrong syntax :)

adb shell "mount -o rw,remount /system"

would do in your case (i.e. passing the command you want to run on the device to adb shell in double-quotes; the "exit" is not needed here as it is "implied"), provided your device's ADB daemon runs in root mode. You can even run multiple commands at once this way, e.g.:

adb shell "mount -o rw,remount /system && echo 127.0.0.1 foobar.com > /system/etc/hosts && mount -o ro,remount /system"

Commands connected with && here, meaning: only execute the next command if the previous one succeeded. If you don't want that dependency, use ; instead to connect them.

For how to use a multi-line command (so called "HEREDOC") with Windows (or any other OS), SuperUser is the better place to ask (in case the Wikipedia entry is not sufficient ;)

  • Thanks. Do you have anything better than this? Concatenating three commands is not my idea of scripting commands over adb. I would be interested in something like the OP describes - a text file with commands to be run over adb. – jww Aug 31 '18 at 19:21
  • @jww then create a script and run each command separately (with the script stored at your PC), or run the script itself on your device. – Izzy Aug 31 '18 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.