Batch file command output to variable

izakfilmalter

Distinguished
Nov 9, 2011
3
0
18,510
Im setting up a batch file to run some adb commands on my android phone. I want to run a command and store the result into a variable for later use in the batch file.

example command:
adb shell getprop ro.product.brand

That command outputs the brand of the device e.g. samsung. I want to capture that without displaying it into a variable that will be used later on in the script. I have the 3 adb files coped over to the scripts location so that it will run natively.
 

izakfilmalter

Distinguished
Nov 9, 2011
3
0
18,510
I have been trying that. Here is my current code:

ECHO Model Information
SET BRAND=adb shell getprop ro.product.brand
ECHO %BRAND%

What happens is the command gets stored as the variable and when it gets echoed it shows: adb shell getprop ro.product.brand instead of samsung.
 

izakfilmalter

Distinguished
Nov 9, 2011
3
0
18,510


Ya I just tried that and its not working. Ive been using this as a solution but its not very elegant:

adb shell getprop ro.product.brand > tmpFile
SET /p PRODUCTBRAND= < tmpFile
DEL tmpFile
 

Latest posts