提问人:Trisiegt 提问时间:7/31/2023 更新时间:7/31/2023 访问量:51
如何从 ADB 获取数据并将其输出到 CMD 变量?
How do I get the data from ADB and output it to a CMD variable?
问:
请问你能尝试修复我愚蠢的代码吗? 我想这样做:
adb shell pidof [android_pkg]>>ISAPPON
,但这行不通,因为它仍然认为它是 ADB 命令。
C:\Users\[BLANK]>adb shell pidof [android_pkg]>>ISAPPON
C:\Users\[BLANK]> echo %ISAPPON%
%ISAPPON%
我尝试了上述方法,但无济于事。 我希望它将 %ISAPPON% 值设置为 [APP PID],但它只是保留并保留了默认值。
-特里西格特
答:
0赞
Mohammad Fallah
7/31/2023
#1
您可以使用(适用于 Windows)
for /f %G in ('adb shell pidof [android_pkg]') do set "ISAPPON=%G"
适用于 Linux 和 Mac
ISAPPON=$(adb shell pidof [android_pkg])
评论