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 ?