Use 'FOR' command if you want: (yea this one only execute 1 command)
For /f "tokens=*" %%a in ('ECHO Hello world') do (
echo %%a
echo %%a >text.txt
)
But the solution below only useful if you want to send both output to console and file a command that show a lots of texts like 'SET' command.
So what about you create an external batch file then use it in your main file?
Example: Code for 'printBoth.bat'
@echo off
setlocal ENABLEDELAYEDEXPANSION
set string=
:loop
set string=!string!%1
shift
if not "%1"=="" goto loop
For /f "tokens=*" %%a in ('!string!') do (
echo %%a
echo %%a >text.txt
)
Now if you want to print to both console and file, just type this code: call printBoth.bat [type command in here]