Batch file command output to variable

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.
5 answers Last reply
More about batch file command output variable
  1. I would think you would set up a user environment variable, then put its location at end of path variable.

    If using many variables, put them in a folder, put folder location in path.


    http://searchsystemschannel.techtarget.com/feature/Setting-Windows-7-environment-variables
  2. 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.
  3. SET BRAND='adb shell getprop ro.product.brand'
  4. Those should be back ticks not single quote marks.
  5. 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
    SET /p PRODUCTBRAND= < tmpFile
    DEL tmpFile
Ask a new question

Read More

Phones Android Command Prompt Windows 7