-2

Fake code Begin----

@echo off

set result = adb shell ifconfig|findstr cast

echo Result=%result%

pause

Fake code End----

I want to get result to do other things.

For example:

adb connect result(let's say result is a ip address)

Chinese Cat
  • 5,108
  • 2
  • 14
  • 15
  • 2
    Does this answer your question? [How do I get the result of a command in a variable in windows?](https://stackoverflow.com/questions/108439/how-do-i-get-the-result-of-a-command-in-a-variable-in-windows) Note that since there's a pipe, you'll have to use `for /f "delims=" %%A in ('adb shell ifconfig ^| findstr "cast"') do set "result=%%A"` – SomethingDark May 18 '22 at 05:02
  • @SomethingDark Yes, but I tried your comand line and an error happened :" %%A shouldn't be here". You got what I want to ask but this command line can't work as we expected. – Chinese Cat May 18 '22 at 08:45
  • 1
    Your "Fake code" start with `@echo off` command that suggest that it will be included in a Batch `.bat` file. If you want to execute it from the command line, just use one percent sign instead of two: `for /f "delims=" %A in ('adb shell ifconfig ^| findstr "cast"') do set "result=%A"` – Aacini May 18 '22 at 16:27

0 Answers0