2014-07-12 56 views
0

我想创建一个批处理,其中用户被问这样的一个选择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 

这样当你给一个错误的答案,你会被重定向到:没有

+1

你有没有尝试过“转到:没有”没有如果在之前呢? –

回答

0
@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 
0

虽然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的

0

好吧,我知道我做了一个错误的问题,我真正想要做的是创造一个激活系统批量。 因此,当我插入正确的代码时,它应该提取和密码保护.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 

但它似乎没有工作...

+0

主题在这里继续:http://stackoverflow.com/questions/24724633/batch-licensing-system – foxidrive