It does not work.
Zack, why post code that does not work.
Rather than prove anything, it paints you as a novice.
My bad long day, i advised a better solution, the file will turn each individual line into its own variable, which can be recalled throughout multiple lines. also i was hoping that people would know not actualy to type command 1,2, or 3. it was just an example. hope this helps now that my brain is working correctly lol.
you could select from a specific line from your "file.txt" or whatever you need, just be sure to replace it's file name with a different file name that has the code you need to use.
@echo off
setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%a in (file.txt) do (
set /a c+=1
set x[!c!]=%%a
)
set x
pause
what ever appears in the prompt, add percentage signs around it.
for example; if you had a line that said "echo hello" inside "file.txt" and you wanted to find that specific line and turn it into a variable, it would display this.
x[1]=echo hello
so in your original batch file you would turn it into %x[1]% and it will display "echo hello" from line x[1] inside of "file.txt". if you wanted it to store more lines to make your variable larger you could do so as you wish. you can also put your %x[1]% variable inside the second variable (%[x2]%) if you wanted a single variable with multiple lines. then use my previous command "set nl=^& echo." inside of it as well to avoid two lines of code to appear on the same line. thus resulting in one multi lined variable.
working on an example so give me a minute