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

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

1 Answer 1


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 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, 2018 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, 2018 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .