2012-07-28 68 views
0

我的短批处理文件一直失败。我的if有什么问题?超级简单的错误,批处理语句

:user 
set /p usercommand = "Input: " 

if %usercommand% equ "done" 
echo got here! 
goto end 

else 
echo not done 
goto user 

回答

2

第一 - 与set /p usercommand =您设置名为usercommand<space>变量。删除预定名称后的空格(因此它变成了set /p usercommand=)。

也就是说,如果其他语法不正确,您将会将您带入另一个错误中作为。它必须是:

if "%usercommand%" equ "done" (
your commands here 
) else (
your commands here 
) 

请注意我报价为%usercommand%。没有这一点,你的比较永远不会是真实的(除非你需要你的输入被明确引用)