Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 超级简单错误,批处理if语句_If Statement_Batch File - Fatal编程技术网

If statement 超级简单错误,批处理if语句

If statement 超级简单错误,批处理if语句,if-statement,batch-file,If Statement,Batch File,我的短批处理文件一直失败。我的if有什么问题 :user set /p usercommand = "Input: " if %usercommand% equ "done" echo got here! goto end else echo not done goto user 首先-使用set/p usercommand=设置名为usercommand的变量。删除预期名称后的空格(因此它变为set/p usercommand=) 这就是说,这将使您遇到另一个错误,因为if-else语法

我的短批处理文件一直失败。我的if有什么问题

:user
set /p usercommand = "Input: "

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

else
echo not done
goto user

首先-使用
set/p usercommand=
设置名为
usercommand
的变量。删除预期名称后的空格(因此它变为
set/p usercommand=

这就是说,这将使您遇到另一个错误,因为if-else语法不正确。它必须是:

if "%usercommand%" equ "done" (
 your commands here
) else (
 your commands here 
)
请注意,我引用了
%usercommand%
。否则,您的比较将永远不会是真实的(当然,除非您要求明确引用您的输入)