将多个单词回显到一个文件会使它崩溃。 (批)

Echoing more than one word to a file makes it crash. (BATCH)

所以我正在批量创建一个邮件程序,但我在消息传递部分遇到了问题。 消息传递部分是一个无限循环。 当我输入多个单词时,它会崩溃。 这是代码。请帮忙!

:rep
set line=
set /p line=
if %line% == end set end= 1
if %line% == end echo. >>"\FAMILY-PC\Users\Public\HailDatabase\HailMail\Accounts\%send%\%msgname%".MAIL
if %line% == end set line= From, %user%
echo %line% >>"\FAMILY-PC\Users\Public\HailDatabase\HailMail\Accounts\%send%\%msgname%".MAIL
if %end% == 1 goto msgdone
goto rep

基本上所有内容都需要引号以保留 %line% 中的空格。此外,您的 if 语句可以 而不是 == 周围有空格,因为批处理会将这些空格解释为要比较的字符串的一部分,您将始终得到一个错误的结果。

:rep
set "line="
set /p "line="
if "%line%"=="end" set "end=1"
if "%line%"=="end" echo. >>"\FAMILY-PC\Users\Public\HailDatabase\HailMail\Accounts\%send%\%msgname%.MAIL"
if "%line%"=="end" set "line= From, %user%"
echo %line% >>"\FAMILY-PC\Users\Public\HailDatabase\HailMail\Accounts\%send%\%msgname%.MAIL"
if "%end%"=="1" goto msgdone
goto rep