0

so I'm trying to run some ADB commands through a powershell script.

This is a simple example of what I am trying to do:

adb shell "
echo "in adb shell"
su root
echo "you are now root."
ls
cd /data/data
echo "in /data/data"
ls
"

I saw in a previous post to add the "" next to shell and at the bottom but that still didn't work for me. I can start the shell and the first ls works. but it just prints the rest of the commands out instead of doing them. The output I am getting looks like:

PS C:\Scripts> & .\test.ps1
: not found/sh:
in adb shell
su root
echo you are now root.
ls
cd /data/data
echo in /data/data
MSM8960_lpm.rc
acct
cache
.
.
.
ueventd.qcom.rc 
ueventd.rc 
vendor PS C:\Scripts>

Any help would be greatly appreciated. Thanks in advance!

Note: the path to ADB is within the powershell $env:path so the adb commands are working

1
  • Doing some more testing... If a do adb shell "ls; ls" bot commands work. The problem is when I try to get root access. When I do: adb shell "su root; ls" it gets hung up after gaining root. So the prompt gets stuck at # Commented Aug 4, 2014 at 14:26

1 Answer 1

2

I was able to get around this by doing:

adb shell "su -c '[cmd]; [cmd]' "

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.