You can put a command line into a variable, but a variable is not intended to hold a page of data.
If you had used this by itself (instead of echo %answer%
)then it would display the dir output:
%answer%
Вопрос
What I tried to do is put dir in "Answer" variable. The variable's result have nothing inside it. What did I do wrong?
@echo off
set /p name=Program name:
echo %name%
set Answer=dir /s /a /b C:\%name%
echo %Answer%
Pause
Решение
You can put a command line into a variable, but a variable is not intended to hold a page of data.
If you had used this by itself (instead of echo %answer%
)then it would display the dir output:
%answer%