我这里有这个代码:
:a
set /p unit=Unitpile Entry:
echo %unit% >> unitpile.txt
if %unit% EQU exitscript (
goto b
) else (
goto a
)
并且只要%unit%中有空格,所以它是两个单词,文件关闭。 请帮助......或者它与语法有关。 顺便说一下,我确实拥有所有其他合适的标签,只是这是整个代码的片段。
答案 0 :(得分:0)
这是您的批处理代码,其中包含一些注释。你可以在这里看到如何正确使用双引号。
:a
rem Define environment variable unit with a double quote as default value.
set "unit=""
set /p "unit=Unitpile Entry: "
rem Remove all double quotes entered by user. If the user has not entered
rem anything, the default double quote is removed. The default is necessary
rem in case of user enters nothing to make the next line working also in
rem this special case.
set "unit=%unit:"=%"
rem Has the user entered anything at all?
if "%unit%"=="" goto :EOF
echo %unit%>>unitpile.txt
if /I "%unit%"=="exitscript" (
goto b
) else (
goto a
)
:b