-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
  • 31,767
  • 12
  • 51
  • 89
Corey
  • 1,094
  • 3
  • 19
  • 36

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.
  • 28,775
  • 16
  • 113
  • 160