Question

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
Était-ce utile?

La solution

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% 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top