【问题标题】:Save result adb command in set /p name= (Bat file)将结果 adb 命令保存在 set /p name=(Bat 文件)中
【发布时间】:2016-06-26 23:46:04
【问题描述】:

我想将下面adb 命令的结果作为变量保存在我的脚本中,但结果错误。

adb shell getprop ro.product.brand

输出:三星

adb shell getprop ro.product.model

输出:SM-G920I

set /p Brand=adb shell getprop ro.product.brand
set /p Model=adb shell getprop ro.product.model
echo Brand: %Brand% Model: %Model% > Test.txt

但结果是:

Brand: 0 Model: 0 

有什么建议吗?

【问题讨论】:

  • 您使用for /f 循环来解析命令输出。对于单行输出 - for /f "delims=" %A in ('adb shell getprop ro.product.brand') do echo %A。在批处理脚本中,输入命令时使用%%A 而不是%A
  • 0 的值从何而来?
  • 感谢帮助我得到了我想要的结果

标签: android shell batch-file adb


【解决方案1】:

在评论中给出的帮助下,我得到了答案

for /f "delims=" %%A in ('adb shell getprop ro.product.brand') do SET brand=%%A
for /f "delims=" %%B in ('adb shell getprop ro.product.model') do SET model=%%B
echo Marca\Modelo > Test.txt
echo %brand%\%model%  >> Test.txt

回答

Marca\Modelo 
samsung\SM-G920I  

【讨论】:

    猜你喜欢
    • 2011-07-16
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-30
    相关资源
    最近更新 更多