我的所有批处理文件都出现了语法不正确的问题

时间:2022-06-04 00:37:32

I am trying to just make a casual conversation using notepad as a batch file creator but whatever I search and try, it keeps saying the syntax of the command is wrong.I was just making it and went to test it and it came up. I have tried doing other stuff on different lines and then set /p ... but it never works. What am I doing wrone; I just want to continue on my just-for-fun project. Thanks:

我正在尝试使用记事本作为批处理文件创建者进行随意的对话,但无论我搜索和尝试,它一直说该命令的语法是错误的。我只是制作它并去测试它并且它出现了。我尝试在不同的行上做其他的东西然后设置/ p ...但它永远不会工作。我在做什么呢我只想继续我的有趣项目。谢谢:

%echo off
set /p name="Hello, what's your name?"
set /p S?1="Oh, well: hello %name%! Is that what you would like me to call you? (Y/N)"
if /i "%S?1?%" EQU "Y" goto :Yes
if /i "%S?1%" EQU "N" goto :No
goto :No answer
:Yes
echo Okay! Just making sure so I do not get on your nerves!
goto :Next1
:No
set /p name="Oh, then what shall I call you, then?"
echo Oh, alright. I will cal you %name% from now on! Sorry.
goto :Next1
:No answer
echo Sorry, but I do need an answer.
timeout 1
:No answer again
set /p S?2=So, is that what you would like me to call you? (Y/N)
if /i "%S?2%" EQU "Y" goto :Yes
if /i "%S?2%" EQU "N" goto: No
goto :No answer again
:Next1
pause

1 个解决方案

#1


2  

Get rid of the extra question mark on line four, (typo).

摆脱第四行的额外问号,(错字)。

Then change your labels.

然后更改标签。

Labels are single strings without spaces, so some of them are returning to :No because it sees "No", "No Answer" and "No Answer Again" as the same. I'd suggest you change them perhaps to :No, :Answer and :Again.

标签是没有空格的单个字符串,因此其中一些字符串返回:否,因为它看到“No”,“No Answer”和“No Answer Again”同样如此。我建议你改变它们:不,:答案和:再说一次。

#1


2  

Get rid of the extra question mark on line four, (typo).

摆脱第四行的额外问号,(错字)。

Then change your labels.

然后更改标签。

Labels are single strings without spaces, so some of them are returning to :No because it sees "No", "No Answer" and "No Answer Again" as the same. I'd suggest you change them perhaps to :No, :Answer and :Again.

标签是没有空格的单个字符串,因此其中一些字符串返回:否,因为它看到“No”,“No Answer”和“No Answer Again”同样如此。我建议你改变它们:不,:答案和:再说一次。