2015-07-06 119 views
0

製作批處理程序,我似乎遇到了if和else語句的問題。DOS批處理文件:如果其他轉到語句理解?

我想讓它轉到另一行,如果有其他東西,然後「列表」鍵入。

有人能告訴我我做錯了什麼嗎?

代碼:

@echo off 
:start 
echo PROVOLONE------------------------- 
echo ------------------------------TEAM 
echo -------------PRESENTS------------- 
echo The Simple Batch Program Collection 
echo 2015 Provolone Team 
sleep 3 
echo. 
echo First, let's start off by listing what programs we have. 
sleep 2 
goto tutorial 
:tutorial 
echo type in "list" 
set /p list="provolone>" 
if %list%== "list" goto list else goto wronglist 
:wronglist 
echo I said type in "list!" not %list% ! 
sleep 2 
goto tutorial 
:list 
echo. 
echo All SBPC Programs as listed 
echo starting with program names 
echo placeholder 
pause 

回答

0

引號包含在比較,所以你需要他們在兩側對比:

if "%list%"== "list" goto list else goto wronglist 
+0

也就是說,而且是官方的,應該不存在「%list%」==「list」'中的等號之間的空格 – UnknownOctopus