windows 如何“回显”批处理文件中的变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38423506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:37:38  来源:igfitidea点击:

How do I "echo" a variable in a batch file?

windowsbatch-fileecho

提问by harrison4354

I typed in this:

我输入了这个:

:Password1
Echo so, make up a password for your info.
Set /p %password%=
echo OKAY! your password is %password% , right?
echo (Y/N)

and it comes out as this:

结果是这样的:

So, make up a password for your info.
(me:) Password
OKAY! your password is , right?

I want it to say

我要它说

"OKAY! your passsword is "Password", right?"

回答by Chamindu

Your set statement is wrong you should not use % there. It should be

你的 set 语句是错误的,你不应该在那里使用 % 。它应该是

set /p password=

回答by Yesreg

All you need to do is remove the %% when typing in your set command. This is what it should be:

您需要做的就是在输入 set 命令时删除 %% 。这是应该的:

:Password1
Echo so, make up a password for your info.
Set /p password=
echo OKAY! your password is %password% , right?
echo (Y/N)