简体   繁体   中英

Running ADB commands through powershell

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

I was able to get around this by doing:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM