2016-06-26 5 views
0

Ich möchte das Ergebnis der adb Befehle unten als Variable in meinem Skript speichern, aber das Ergebnis ist falsch.Speichern Ergebnis adb Befehl in set/p Name = (Bat-Datei)

adb shell getprop ro.product.brand 

Ausgang: Samsung

adb shell getprop ro.product.model 

Ausgang: 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 

Aber das Ergebnis ist:

Brand: 0 Model: 0 

Irgendwelche Vorschläge?

+0

Sie verwenden eine 'für/f' Schleife Befehlsausgabe zu analysieren. Für eine einzelne Zeilenausgabe - 'for/f" delims = "% A in ('adb shell getprop ro.product.brand') echo% A'. Verwenden Sie in einem Stapelskript '%% A' anstelle von'% A', wenn Sie Befehle eingeben. –

+0

Woher kommen die Werte "0"? – aschipfl

+0

Danke für die Hilfe Ich habe das Ergebnis, das ich will –

Antwort

1

Mit Hilfe im Kommentar gegeben bekam ich die Antwort

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 

Antwort

Marca\Modelo 
samsung\SM-G920I 
Verwandte Themen