Running ADB commands through powershell

2019-03-04 11:33发布

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条回答
SAY GOODBYE
2楼-- · 2019-03-04 12:03

I was able to get around this by doing:

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

查看更多
登录 后发表回答