Setlocal enableDelayedExpansion Is your friend for this use.
The below example Sets commands to an array, To assign them to Distinct names you'd need to modify the For loop or Process the Array a second time to reassign them to new variable names.
Here's the example script with Ansi Character intact:
@ECHO OFF :start Set Processed=0 Set "Val=0" color 07 SETLOCAL ENABLEDELAYEDEXPANSION :DefineArrays FOR /F "tokens=* USEBACKQ Delims=#" %%c in ("target.bat") do ( Set /a "Val+=1" SET "ScreenArray[!Val!]=%%c" ) :UseObjects FOR /L %%a in (1,1,10) DO !ScreenArray[%%a]! 2>nul pause exit
and example source: target.bat
#Mode 1000 #ECHO Testing Array #TIMEOUT 1 #MODE con: cols=50 lines=30 #ECHO Definement Of Objects #TIMEOUT 1 #MODE 1000 #ECHO For Use in Batch #TIMEOUT 1 #CALL "%userprofile%\Desktop\target.bat" Set "msg=[34mYour Message Here[0m" @ECHO %msg% TIMEOUT 1 :screen @ECHO OFF cls color 02 mode con: cols=93 lines=13 ECHO ============================================================================================ ECHO = [33mLibrary of Objects as Commands, Functions and Programs for assignment to Array Elements[32m ECHO = ECHO = [36mTesting is Complete.[32m ECHO = ECHO = [36mYou now have the tools to use arrays Within Batch.[32m ECHO = ECHO = [36mdeveloped by: [37mT3RRY.[32m ECHO = ECHO ============================================================================================[0m TIMEOUT 4 CLS GOTO :EOF
%TestWadom%as it'll be a major injection security issue