-6

According to How do I get the result of a command in a variable in windows?

Changing the command from date to adb devices, the output becomes weird.

Here is my code

@echo OFF 
FOR /F "delims=" %%i IN ('adb devices /t') DO set today=%%i
echo %today%
pause

Output:

Usage: adb devices [-l]

Try in another way

@echo OFF
set adbstart=C:\Users\kuanlinchen\AppData\Local\Android\sdk\platform-tools\adb devices
FOR /F "delims=" %%i IN ('call %adbstart% /t') DO set today=%%i
echo %today%
pause

Also output:

Usage: adb devices [-l]

If I run adb devices in this way, works fine.

@echo OFF
adb devices
pause

Output:

List of devices attached
XXXXXXXXXXXX    device

What does the weird output Usage: adb devices [-l] means ?

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Corey
  • 1,217
  • 3
  • 22
  • 39

1 Answers1

2

adb devices command does not have the /t parameter. In case of an invalid parameter error adb shows its proper usage message.

Alex P.
  • 30,437
  • 17
  • 118
  • 169