halcyon27
halcyon27

Reputation: 169

send output of batch file with adb commands to vbscript

This shouldn't be tough, but my knowledge is very limited.

I would like to get the values returned by the following adb commands:

adb shell getprop ro.product.brand
adb shell getprop ro.product.model
adb shell getprop ro.build.version.release

and assign the values to variables which are passed into a vbscript.

I have tried without success:

set adb shell getprop ro.product.brand=deviceBrand
echo %deviceBrand&

This is really two issues (1. assign variable, 2. pass to vbscript). I am just looking for help on step 1. here.

EDIT

Thanks to Aacini I now have the adb commands as variable using For /F. Below is my current code:

for /F "delims=" %%a in ('adb devices') do set devices=%%a

rem get the values returned by the following adb commands into variables:
for /F "delims=" %%a in ('adb shell getprop ro.product.manufacturer') do set mfg=%%a
for /F "delims=" %%a in ('adb shell getprop ro.product.brand') do set brand=%%a
for /F "delims=" %%a in ('adb shell getprop ro.build.PDA') do set pda=%%a 
for /F "delims=" %%a in ('adb shell getprop ro.product.model') do set model=%%a
for /F "delims=" %%a in ('adb shell getprop ro.build.version.release') do set os=%%a
for /F "delims=" %%a in ('adb shell getprop ro.product.locale.language') do set language=%%a
for /F "delims=" %%a in ('adb shell getprop ro.product.locale.region') do set region=%%a
for /F "delims=" %%a in ('adb shell getprop ro.build.target_country') do set country=%%a
for /F "delims=" %%a in ('adb shell getprop ro.build.target_operator') do set operator=%%a
for /F "tokens=1 delims=" %%a in ('adb shell dumpsys package com.my.package1^|find "version"') do set package1=%%a
for /F "tokens=1 delims=" %%a in ('adb shell dumpsys package com.my.package2^|find "version"') do set package2=%%a

However, I am still getting lost passing it to vbscript. With the code Aacini provided, I expected to see a file created called "theScript.vbs", but I don't.

Upvotes: 0

Views: 1847

Answers (2)

Aacini
Aacini

Reputation: 67226

rem get the values returned by the following adb commands into variables:
for /F "delims=" %%a in ('adb shell getprop ro.product.brand') do set brand=%%a
for /F "delims=" %%a in ('adb shell getprop ro.product.model') do set model=%%a
for /F "delims=" %%a in ('adb shell getprop ro.build.version.release') do set version=%%a

rem pass these variables into a vbscript:
cscript //nologo theScript.vbs

Into TheScript.vbs:

set wshell = WScript.CreateObject("WScript.Shell")
set env = wshell.Environment("PROCESS")
set brand = env("brand")
set model = env("model")
set version = env("version")

I am not totally sure of the VBS syntax to get the value of variables, but a search on this site will give specific details.

Upvotes: 1

Amit Chauhan
Amit Chauhan

Reputation: 6889

You can try by Storing values in temp. File and read from the file or Setting value in Environment variable of OS.

Upvotes: 0

Related Questions