我想創建一個批處理,其中用戶被問這樣的一個選擇PROGRAMM:批量選擇與錯誤的答案
@echo off
:choice
set /P c=What is 2+2
if /I "%c%" EQU "4" goto :yes
if /I "%c%" EQU "WHAT DO I TYPE IN HERE?" goto :no
:yes
msg * well done
pause
exit
:no
exit
這樣當你給一個錯誤的答案,你會被重定向到:沒有
我想創建一個批處理,其中用戶被問這樣的一個選擇PROGRAMM:批量選擇與錯誤的答案
@echo off
:choice
set /P c=What is 2+2
if /I "%c%" EQU "4" goto :yes
if /I "%c%" EQU "WHAT DO I TYPE IN HERE?" goto :no
:yes
msg * well done
pause
exit
:no
exit
這樣當你給一個錯誤的答案,你會被重定向到:沒有
@echo off
:choice
set /P c=What is 2+2
if /I "%c%" EQU "4" (goto :yes) else (goto :no)
:yes
msg * well done
pause
exit
:no
exit
雖然foxidrive的回答是最適合你了,如果你正在尋找的compare-op
不等於例子,它是:
if "%c%" NEQ "4" Echo Wrong...
其他比較運算的包括:
where compare-op may be one of:
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equal
從if /?
引用。
您還可以使用:
if NOT "%c%"=="4" Echo Wrong...
這樣做沒有比較-OP的
好吧,我知道我做了一個錯誤的問題,我真正想要做的是創造一個激活系統批量。 因此,當我插入正確的代碼時,它應該提取和密碼保護.rar或一個sfx(.exe)文件。 這就是爲什麼我需要它,這就是我現在真的有:
@echo off
:choice
set /P c=Insert Key
if /I "%c%" EQU "123" goto :yes
if /I "%c%" EQU "321" goto :yes
if /I "%c%" EQU "132" goto :yes
:yes
msg * well done
unrar x -p"password" "filename.rar"
pause
exit
:no
exit
但它似乎沒有工作...
主題在這裏繼續:http://stackoverflow.com/questions/24724633/batch-licensing-system – foxidrive
你有沒有嘗試過「轉到:沒有」沒有如果在之前呢? –