如何在set / p命令后使用echo命令

时间:2010-12-01 03:30:05

标签: batch-file set hidden

我想让这个脚本以某种方式工作,但我发现你使用

之后
set /p variable= whater you want here

如果你之后使用echo命令,它的隐藏或其他东西,因为它不会出现......

@echo off 
cls 
color A 
:MAIN 
cls 
echo. 
echo. 
echo ================================= 
echo. set /p var= what is your name? 
:: DOES NOT SHOW UP (STARTING HERE) 
echo. 
echo ================================= 
:: DOES NOT SHOW UP (ENDING HERE) 
set /p answer= so your name is %var%? 
IF %answer%== yes echo thats an amazing name! 
IF %answer%== no goto MAIN 

言论所包围的部分不想出于某种原因......任何想法?

3 个答案:

答案 0 :(得分:5)

如果我理解你要做什么,这就是你需要的代码:

@echo off  
cls  
color A  
:MAIN  
cls  
echo =================================  
echo what is your name?  
echo =================================  
set /p var=
set /p answer= so your name is %var%?  
IF [%answer%] == [yes] echo thats an amazing name!  
IF [%answer%] == [no] goto MAIN  
pause

答案 1 :(得分:3)

由于处理器将在打印what is your name?后等待用户输入(由于/p),因此您无法获得下一行========等。直到输入被按下。

答案 2 :(得分:1)

它显示给我,我得到了

=================================
 set /p var= what is your name?

=================================
 so your name is ? Andy

我期待的是什么,你期待什么?