批处理 - 设置/ p功能不起作用

时间:2014-02-20 14:22:06

标签: batch-file if-statement set

我有一个批量游戏,我正在尝试制作一个脚本,这样他们就可以做出选择,他们想做什么。我做了一些研究,我找到了set /p anytext=的方法。它似乎工作,因为它在我的测试文件上,但当我尝试在我的Jigsaw.bat上使用它时,它不会工作。当我键入1或2时,它唯一要做的就是按任意键继续并退出批处理文件。为了清理问题,这里有一段代码......

Jigsaw.bat

    :Options
        echo ----------------------------------------------------Pick Your Fate--------------------------------
        echo When prompted, choose 1 for choice 1,  2 for choice 2, and so on...
        echo 1) Pass: Shutdown Fail: shutdown loop...
        echo 2) Pass: Spammed till crash Fail: Spammed till crash everytime your PC Starts Up
        echo 3) Pass: You Are Free To Go Fail: Deletes System 32 Files
        echo 4) Pass: Free to Go (Nearly Impossible) Wouldn't do it. Fail: Deletes System 32 Files
        echo 5) Special Number 5... Pass: Do a different fate Fail: Do all the fates, including 5 again
        echo -----------------------------------------------------Pick Your Fate-----------------------------------
        set /p hi= 

        if not defined hi ( 
        cls 
        goto loop 
        ) 

        if %hi% == 1 goto 1
        if %hi% == 2 goto 2
        if %hi% == 3 goto 3
        if %hi% == 4 goto 4
    :1
    echo The Rules are simple you have two minutes to stop the shutdown timer, if the timer runs out, you fail.
    echo Press any key to begin, I shall leave you one clue from the start.
    pause
    echo Live or Die: Make your Choice
    pause
    start timer
    start shutdowntimer
echo Clue: If you need it, something that manages every tasks, services and files may come in handy.

我已经做了更多的研究,并且不断陷入死胡同,或者解决我没有的问题,所以我决定在这里问。

1 个答案:

答案 0 :(得分:0)

使用选择

CHOICE /C ABCD /M Select [A] Choice 1 or [B] Choice 2 or [C] Choice 3 or [D] Choice 4 IF errorlevel 4 goto Choice 4 IF errorlevel 3 goto Choice 3 IF errorlevel 2 goto Choice 2 IF errorlevel 1 goto Choice 1