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

发布于 2024-10-05 12:12:13 字数 568 浏览 1 评论 0原文

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

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 

被注释包围的部分不想出现出于某种原因...有什么想法吗?

I wanted to make this script work somehow, but i find that after you use

set /p variable= whater you want here

If you use the echo command after it, its hidden or something because it wont come up...

@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 

The part thats surrounded by the remarks doesnt want to show up for some reason... any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

好久不见√ 2024-10-12 12:12:13

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

@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

If I'm understanding what you are trying to do, this is the code you need:

@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
病女 2024-10-12 12:12:13

因为处理器在打印 what is your name? 后会等待用户输入(由于 /p),所以你不会得到下一行 = =======等等。直到按下回车键。

Because the processor will wait for the user input after printing what is your name? (due to the /p), you will not get the next line of ========etc. until enter is pressed.

£烟消云散 2024-10-12 12:12:13

它出现在我面前,我明白

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

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

这就是我所期望的,你期望什么?

It shows up for me, I get

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

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

Which is what I would expect, what are you expecting?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文