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% 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top