Sign in with
Sign up | Sign in
Your question

Batch file command output to variable

Last response: in Windows 7
November 9, 2011 5:51:19 AM

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.
November 9, 2011 6:41:31 PM

I have been trying that. Here is my current code:

ECHO Model Information
SET BRAND=adb shell getprop ro.product.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.
Related resources
November 9, 2011 6:50:34 PM

SET BRAND='adb shell getprop ro.product.brand'
November 9, 2011 7:02:23 PM

Those should be back ticks not single quote marks.

November 10, 2011 4:10:08 AM

Jim_L9 said:
Those should be back ticks not single quote marks.

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
DEL tmpFile