0

I have a batch game, and I am trying to make a script, so they can make a choice, on what they want to do. I did some research on it, and I found a way by set /p anytext=. It seemed like it worked, because it did on my test file, but when I tried to use it on my Jigsaw.bat, it wouldn't work. When I typed in 1 or two the only thing it would do is say press any key to continue and exit the batch file. To clear things up, here is a snippit of code...

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.

I have done some more research, and keep running into dead ends, or answers to problems I don't have, so I decided I should ask here.

PCJackson
  • 76
  • 1
  • 1
  • 7
  • 2
    Is all that within another loop? – foxidrive Feb 20 '14 at 15:08
  • What @foxidrive is getting at is that you probably need to enable and use delayed expansion. You can find about a thousand questions about it on this site. E.g., http://stackoverflow.com/questions/12423238/ – indiv Feb 20 '14 at 18:36
  • That's good, but I still can't seem to get it to work – PCJackson Feb 20 '14 at 20:45
  • "I still can't seem to get it to work" is not enough information. We can't troubleshoot unless we know exactly what you have tried, what results you were expecting, and what results you got. Without that information, the problem could be anything from a logic error to a typo. – Edward Mar 08 '14 at 03:41

1 Answers1

0

Use CHOICE

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

Carl479
  • 389
  • 2
  • 5
  • 16