Game With The Batch Code Keeps Crashing - batch-file

#echo off
set SCENARIO21=20
set WEAPON1=gun
set DOG1=buddy
set SCENARIO11=broken laptop
set ALIVE1=yes
:day51
cls
echo.
echo Player 1 %SCENARIO21% %WEAPON1% %SCENARIO11%
echo %DOG1%
echo.
echo.
echo Day 5
echo.
echo That was a close one, im glad i got that jacket off when i did...that could've ended really badly...
pause
cls
echo Dang this road seems to go on forever...
pause
cls
echo Woah...
pause
cls
echo That house looks...normal...
pause
cls
echo Is somebody in there?
pause
cls
echo Come on who would live in that house though...
pause
cls
echo Its old, worn down, the roof is bowed, the paint is peeling...
pause
cls
echo And ew...that furniture looks like something from the 2000s
pause
cls
echo Whoever lived there last must've been an old couple...really old...
pause
cls
echo Maybe there is someone in there
pause
cls
echo The windows look like they're sparkling...
pause
cls
echo Wow. Is that a...?
pause
cls
echo A um...what are those called...Oh yeah...
pause
cls
echo A plant?
pause
cls
echo No...it couldn't be
pause
cls
echo The world's last farmer died about 70 years ago...
pause
cls
echo The 2100s...
pause
cls
echo No one knows how to plant anything, let alone GROW anything anymore...
pause
cls
echo Atleast thats what i thought...
pause
cls
echo I wonder if i should go in...
pause
if %ALIVE1%==yes (
cls
echo Player 1
pause
cls
echo Player 1
echo This house gives me a strange feeling...i can't tell if it's good or bad...
echo -Yes (go in, check the house, maybe it has a planting guide...or maybe theres someone in there...and hey if there is someone, why wouldn't they help you)
echo -No (screw that, its not worth it, if you go in your gonna die, duh...anyways what could be of use in a house as old as the 2000s)
set /p SCENARIO51=Should you go in the house?
if %SCENARIO51%==yes (
cls
echo You walk into the home...
pause
cls
echo Hello?
pause
cls
echo *distant voice* Hello...why are you in my home?
pause
cls
echo Sorry sir...ma'm...um i wasn't trying to bother you...
pause
cls
echo *distant voice* You didn't answer my question...and it's sir, thank you...
pause
cls
echo Oh...i came in because i saw the plants outside...
pause
cls
echo *distant voice* And? Is that your only reason...
pause
cls
echo Well i haven't seen plants until now...i was wondering how?
pause
cls
echo *distant voice* YOU'VE NEVER SEEN PLANTS? THIS IS WHY I GO AGAINST THE SYSTEM...
pause
cls
echo What system sir?
pause
cls
echo *distant voice* If we're going to have a conversation come sit with me...walk to the end of the hall and take a left into my room...
pause
cls
echo You walked into the room of the strange voice and found an old man sitting in a chair that looked like a bubble of water being squished...
pause
cls
echo *Old Man* Im Alexander...im 170 years old...
pause
cls
echo H-h-how?
pause
cls
echo *Alexander* Okay i don't have all day i must attend to other things...I'll tell you what
echo I'll answer 1 question...any question...
pause
cls
if %SCENARIO51%==yes
echo This is your chance...
echo -1 (How did this all start?)
echo -2 (How do i get to the city of Lillian?)
echo -3 (How do i live forever just like you?)
set /p SCENARIOP51=What would you like to ask?
if %SCENARIOP51%==1 (
cls
echo *Alexander* Wow...good question...
echo It started in 2100...
pause
cls
echo When the last farmer died?
pause
cls
echo *Alexander* No, when the last farmer turned immortal...me
pause
cls
echo No i saw it on the news drone...he's dead...
pause
cls
set CODE=LSON5676
echo *Alexander* AGAIN...Sorry, that was the system's news drone...they tend to "confuse" everyone's story to make themselfs look better...
echo Anyways...in 2100 two groups of hacking experts went to war...
pause
cls
echo It ended when one of the groups found a way to literally melt the other groups computers into green radioactive goop...
echo No one really knows for sure how the war was started but most say it was because one group had a hostage...
pause
cls
echo The hostage was said to be the head hacker for the opposing group that was finding some cure...his name was Larson...
echo But for some reason when asking for Larson back the opposing group requested they send %CODE% back...
pause
cls
echo That sounds like a code...
echo better write it down...
echo %CODE%
pause
cls
echo *Alexander* It was all for some stupid reason in my opionion anyways...
echo But back to what happened...
echo After they figured out how to turn the computer into this green goop..they did it to all their computers...
echo Little did they know the goop became radioactive Artificial Intelligence...it could think on its own...
echo And it spread like wild fire...any technology it touched became more green goop...
echo Something else they didn't realize is the goop could sink into your skin with no problem at all...
echo It goes into your veins and overclocks your heart...
echo It was a nano-technology weapon...atomic level capabilities...
echo It was a devastation...
echo And thats all i know...
pause
cls
echo Thank you Alexander...this information won't go to waste...
pause
set ALIVE1=yes
)
if %SCENARIOP51%==2 (
cls
set CODE=5676
echo *Alexander* HA! thats simple...
echo you're not that far either...
echo Go down the road and take the 3rd right
echo You'll be right in front of it...
pause
cls
echo You followed his advice and fell into a trap
pause
cls
type "the end.txt"
pause
cls
set ALIVE1=no
)
if %SCENARIOP51%==3 (
cls
echo *Alexander* Come with me ill show you...
echo This guy seems kinda fishy...
echo Go (go with Alexander to find out what makes him live forever)
echo Leave (Don't follow Alexander, say you have a group waiting outside and you need to get back to them...)
)
if %SCENARIOP51%==3 (
set /p SCENARIOPP51=Do you want to follow Alexander?
)
if %SCENARIOP51%==3 (
if %SCENARIOPP51%==go (
cls
set CODE=LSON5676
echo *Alexander* you aren't smartest are you?
pause
cls
echo You turn around and...
pause
cls
echo *BANG*
pause
cls
echo You died...
pause
cls
type "the end.txt"
pause
set ALIVE1=no
)
if %SCENARIOPP51%==leave (
cls
set CODE=LSON5676
echo *Alexander* I know you're not with anyone but that dog of yours %DOG1%...
pause
cls
echo How do you know his name?
pause
cls
echo *Alexander* you called him to come as you walked down the street cause he was sniffing something...i over heard...
echo I respect your efforts to not fall into traps though...
echo Take this...
pause
cls
echo Alexander handed you a small square of yellow paper with the writing %CODE% on it...
pause
cls
echo *Alexander* take the sticky note and get out...
pause
cls
echo You take the sticky note and leave the house...
pause
cls
echo Whats a sticky note?
pause
)
)
if %SCENARIO51%==no (
cls
echo That thing gives me the creeps...
echo Bye bye house of horror...
set SCENARIO51=none
pause
set ALIVE1=yes
)
)
)
set END=0
if %ALIVE1%==no (
set /a END=%END%+1
)
if %END%==1 (
exit
)
goto day61
:day61
echo yay!
pause
exit
I've tried everything, im very new to coding hence the simple codes but im so confused on what's wrong. I've been coding this 4 player game for about 4 days and i've been stuck trying to fix this specific code. Whenever i load up the game I can get here and get through each scenario but then for instance if i chose to ask the first question I could get through all the dialogue BUT the %CODE% doesn't show up because #echo is off. Also, after completing the 1st question it will still ask me this part:
if %SCENARIOP51%==3 (
cls
echo *Alexander* Come with me ill show you...
echo This guy seems kinda fishy...
echo Go (go with Alexander to find out what makes him live forever)
echo Leave (Don't follow Alexander, say you have a group waiting outside and you need to get back to them...)
)
if %SCENARIOP51%==3 (
set /p SCENARIOPP51=Do you want to follow Alexander?
)
Even though %SCENARIOP51%==1 it still has me set /p SCENARIOPP51 even though %SCENARIOP51% doesn't equal 3. Please Help It Would Be Veryyyyyy Appreciated. Thanks! :)

if %ALIVE1%==yes (
cls
echo Player 1
pause
cls
echo Player 1
echo This house gives me a strange feeling...i can't tell if it's good or bad...
echo -Yes (go in, check the house, maybe it has a planting guide...or maybe theres someone in there...and hey if there is someone, why wouldn't they help you)
Note that this fortuitous? ) ends the if. If you want to actually show the ) here then you need to escape the ) by coding ^). The drawback though is that your if is then not closed for a large number of lines (I'm not going to look through all that code) - and your if %SCENARIO51% opens (another) nested code-block.
Within a code-block (a parenthesised sequence of lines) any %var% is replaced by the value of that variable when the instruction controlling the block (if, for) is encountered. Hence, your set/p which varies SCENARIO51 will appear to use the previous value of SCENARIO51 for %SCENARIO51% within the block.
You need to look at delayedexpansion - hundreds of SO articles about that.
And also be warned : replying Enter alone to a set/p will leave the variable unchanged.
Since you are using set/p you should also use the format
if "%varname%"=="targetstring" ...
in order to have some immunity to empty/separator-containing strings.
Further, the /i switch applied to if will make the comparison case-insensitive.
And it may benefit you to learn batch subroutines. See call /? from the prompt for documentation.

Related

Why does batch script keep exiting after set /P user prompt?

#echo off
cls
echo Hello, there! Today is
date /t
echo and the current time is
time /t
echo I'm so glad to meet you. My name is Hal 10000.
set /p name=What's your name?
cls
echo Well hello, %name%
echo Hey, %name%, & set /p "age"="how old are you in years?"
echo Well that's just great! I'm actually 115 today.
echo I look pretty good, huh!?
echo Well, gotta go, by!
exit
Looks like you need a pause command. Your code is executing correctly but there is nothing stopping the code from exiting before you see your results.
#Echo off
Echo This message will not be displayed.
cls
Echo This message will be displayed.
pause
exit
Adding a pause before the exit will show your results until a button is pressed.

ls it possible to have 2 words to compare with IF?

#echo off
:menu
echo.
echo Hello! Would you like to play this Quiz game?
ping localhost -n 2 >nul
goto Q1
:Q1
echo.
echo Who is the CEO of Google?
set /p Q1A=
if %Q1A% equ Sundar Pichai goto Welldone;
:Welldone
echo cool
pause
Simple code.
As soon as I answer Q1with the correct answer "Sundar Pichai", the bat file closes.
What am I doing wrong? How can I fix it?
Please help me!
Edit: If I type "SundarPichai" without spaces, it works.
But how do I make it work with spaces?

"set/a was unexpected at this time"

I'm new to batch and am mainly using it for this one school project. I'm also new to stack overflow, so leniency of mistakes would be appreciated. I keep getting the error message "set/a was unexpected at this time" when I get to ":MARK" in the code. I'm just going to dump the entire code here, sorry if it's confusing.
#echo off
color 7C
:MAINMENU
cls
title Main Menu
echo To start the quiz, type 1
echo To view the accreditations, type 2
echo To exit the Shop Quiz, type 3
set/p menuselection= Make your selection:
if %menuselection%==1 goto QUESTIONONE
if %menuselection%==2 goto ACCREDITATION
if %menuselection%==3 goto ENDPROGRAM
:QUESTIONONE
cls
title Question One of Ten
echo What do you do if there is an accident in the shop?
echo.
echo 1. Duck and cover your head to avoid injury
echo 2. Immediately go tell the instructor
echo 3. Walk it off
echo 4. Help the person who got hurt and fix the problem
echo.
set/p aone=
goto QUESTIONTWO
:QUESTIONTWO
cls
title Question Two of Ten
echo What attitude should you always have in the shop?
echo.
echo 1. Calm and careful
echo 2. Focused on surroundings
echo 3. Mischievous and goofy
echo 4. Attentive and ready to avoid injury
echo.
set/p atwo=
goto QUESTIONTHREE
:QUESTIONTHREE
cls
title Question Three of Ten
echo Which of the following is NOT allowed for dress in shop?
echo.
echo 1. Sandals
echo 2. Tucked Loose clothing
echo 3. Crocs
echo 4. Eye Goggles
echo.
set/p athree=
goto QUESTIONFOUR
:QUESTIONFOUR
cls
title Question Four of Ten
echo What list of items must you be able to locate in the shop?
echo.
echo 1. Wood, tool shelf, eye goggles, fire extinguishers, power buttons
echo 2. Fire blankets, first aid kits, fire extinguishers, power buttons, eye goggles
echo 3. Eyewash stations, first aid kits, fire extinguishers, fire blankets, power buttons
echo 4. Eye goggles, fire blankets, tool shelf, fire extinguishers, power buttons
echo.
set/p afour=
goto QUESTIONFIVE
:QUESTIONFIVE
cls
title Question Five of Ten
echo Which of these potential risks is caused by clutter and spills?
echo.
echo 1. Bumping into things
echo 2. Unnecessary strain
echo 3. The drill catching the stock and spinning it
echo 4. Prevention of proper lifting techniques
echo.
set/p afive=
goto QUESTIONSIX
:QUESTIONSIX
cls
title Question Six of Ten
echo Which of these IS an acceptable mental condition for shop work?
echo.
echo 1. Tired
echo 2. Hesitant
echo 3. Rushed
echo 4. Under the influence
echo.
set/p asix=
goto QUESTIONSEVEN
:QUESTIONSEVEN
cls
title Question Seven of Ten
echo Your work station should NOT be:
echo.
echo 1. Adequately ventilated
echo 2. Well-organized
echo 3. Compact
echo 4. Well-lit
echo.
set/p aseven=
goto QUESTIONEIGHT
:QUESTIONEIGHT
cls
title Question Eight of Ten
echo What tool should you use to secure your work?
echo.
echo 1. Wrench
echo 2. Paper weight
echo 3. Vice
echo 4. Your hand
echo.
set/p aeight=
goto QUESTIONNINE
:QUESTIONNINE
cls
title Question Nine of Ten
echo What can you use to hold onto things like nails, screws, or chisels?
echo.
echo 1. Pocket
echo 2. Hands
echo 3. Mouth
echo 4. All of the above
echo.
set/p anine=
goto QUESTIONTEN
:QUESTIONTEN
cls
title Question Ten of Ten
echo Of the following only one action is acceptable. Select it.
echo.
echo 1. Using files without handles
echo 2. Prying with a chisel
echo 3. Using clamps that are really big
echo 4. Hammering with a wrench
echo.
set/p athree=
goto RESULTS
:RESULTS
cls
title Results
goto MARK
:RESULTONE
echo Question one of ten
echo What do you do if there is an accident in the shop?
if %aone%==1 echo "Duck and cover your head to avoid injury" is wrong.
if %aone%==1 echo Correct answer is 2, "Immediately go tell the instructor"
if %aone%==2 echo "Immediately go tell the instructor" is correct.
if %aone%==3 echo "Walk it off" is wrong.
if %aone%==3 echo Correct answer is 2, "Immediately go tell the instructor"
if %aone%==4 echo "Help the person who got hurt and fix the problem" is wrong.
if %aone%==4 echo Correct answer is 2, "Immediately go tell the instructor"
pause
goto RESULTTWO
:RESULTTWO
echo Question two of ten
echo What attitude should you always have in shop?
if %atwo%==1 echo "Calm and careful" is correct.
if %atwo%==2 echo "Focused on surroungings" is wrong.
if %atwo%==2 echo Correct answer is 1, "Calm and careful"
if %atwo%==3 echo "Mischievous" is wrong.
if %atwo%==3 echo Correct answer is 1, "Calm and careful"
if %atwo%==4 echo "Attentive and ready to avoid" is wrong.
if %atwo%==4 echo Correct answer is 1, "Calm and careful"
pause
goto RESULTTHREE
:RESULTTHREE
echo Question three of ten
echo Which of the following is NOT allowed for dress in shop?
if %athree%==1 echo "Sandals" is correct.
if %athree%==2 echo "Tucked loose clothing" is wrong.
if %athree%==2 echo Correct answer is 1, "Sandals"
if %athree%==3 echo "Crocs" is wrong.
if %athree%==3 echo Correct answer is 1, "Sandals"
if %athree%==4 echo "Eye goggles" is wrong.
if %athree%==4 echo Correct answer is 1, "Sandals"
pause
goto RESULTFOUR
:RESULTFOUR
echo Question four of ten
echo What list of items must you be able to locate in the shop?
if %afour%==1 echo "Wood, tool shelf, eye goggles, fire extinguishers, power buttons" is wrong.
if %afour%==1 echo Correct answer is 3, "Eyewash stations, first aid kits, fire extinguishers, fire blankets, power buttons"
if %afour%==2 echo "Fire blankets, first aid kits, fire extinguishers, power buttons" is wrong.
if %afour%==2 echo Correct answer is 3, "Eyewash stations, first aid kits, fire extinguishers, fire blankets, power buttons"
if %afour%==3 echo "Eyewash stations, first aid kits, fire extinguishers, fire blankets, power buttons" is correct.
if %afour%==4 echo "Eye goggles, fire blankets, tool shelf, fire extinguishers, power buttons" is wrong.
if %afour%==4 echo Correct answer is 3, "Eyewash stations, first aid kits, fire extinguishers, fire blankets, power buttons"
pause
goto RESULTFIVE
:RESULTFIVE
echo Question five of ten
echo Which of these potential risks is caused by clutter and spills
if %afive%==1 echo "Bumping into things" is correct.
if %afive%==2 echo "Unnecessary strain" is wrong.
if %afive%==2 echo Correct answer is 1, "Bumping into things"
if %afive%==3 echo "The drill catching the stock and spinning it" is wrong.
if %afive%==3 echo Correct answer is 1, "Bumping into things"
if %afive%==4 echo "Prevention of proper lifting techniques" is wrong.
if %afive%==4 echo Correct answer is 1, "Bumping into things"
pause
goto RESULTSIX
:RESULTSIX
echo Question six of ten
echo Which of these is an acceptable mental condition for shop work?
if %asix%==1 echo "Tired" is wrong.
if %asix%==1 echo Correct answer is 2, "Hesitant"
if %asix%==2 echo "Hesitant" is correct.
if %asix%==3 echo "Rushed" is wrong.
if %asix%==3 echo Correct answer is 2, "Hesitant"
if %asix%==4 echo "Under the influence" is wrong.
if %asix%==4 echo Correct answer is 2, "Hesitant"
pause
goto RESULTSEVEN
:RESULTSEVEN
echo Question seven of ten
echo Your work station should NOT be:
if %aseven%==1 echo "Adequately ventilated" is wrong.
if %aseven%==1 echo Correct answer is 3, "Compact"
if %aseven%==2 echo "Well-organized" is wrong.
if %aseven%==2 echo Correct answer is 3, "Compact"
if %aseven%==3 echo "Compact" is correct.
if %aseven%==4 echo "Well-lit" is wrong.
if %aseven%==4 echo Correct answer is 3, "Compact"
pause
goto RESULTEIGHT
:RESULTEIGHT
echo Question eight of ten
echo What tool should you use to secure your work?
if %aeight%==1 echo "Wrench" is wrong.
if %aeight%==1 echo Correct answer is 3, "Vice"
if %aeight%==2 echo "Paper weight" is wrong.
if %aeight%==2 echo Correct answer is 3, "Vice"
if %aeight%==3 echo "Vice" is correct.
if %aeight%==4 echo "Your hand" is wrong.
if %aeight%==4 echo Correct answer is 3, "Vice"
pause
goto RESULTNINE
:RESULTNINE
echo Question nine of ten
echo What can you use to hold onto things like nails, screws, or chisels?
if %anine%==1 echo "Pocket" is wrong.
if %anine%==1 echo Correct answer is 2, "Hands"
if %anine%==2 echo "Hands" is correct.
if %anine%==3 echo "Mouth" is wrong.
if %anine%==3 echo Correct answer is 2, "Hands"
if %anine%==4 echo "All of the above" is wrong.
if %anine%==4 echo Correct answer is 2, "Hands"
pause
goto RESULTTEN
:RESULTTEN
echo Question ten of ten
echo Of the following only one action is acceptable. Select it.
if %aten%==1 echo "Using files without handles" is wrong.
if %aten%==1 echo Correct answer is 3, "Using clamps that are really big"
if %aten%==2 echo "Prying with a chisel" is wrong.
if %aten%==2 echo Correct answer is 3, "Using clamps that are really big"
if %aten%==3 echo "Using clamps that are really big" is correct.
if %aten%==4 echo "Hammering with a wrench" is wrong.
if %aten%==4 echo Correct answer is 3, "Using clamps that are really big""
pause
goto MAINMENU
:MARK
set mark= 0
if %aone%==2 set/a mark="%mark%+1"
if %atwo%==1 set/a mark="%mark%+1"
if %athree%==1 set/a mark="%mark%+1"
if %afour%==3 set/a mark="%mark%+1"
if %afive%==1 set/a mark="%mark%+1"
if %asix%==2 set/a mark="%mark%+1"
if %aseven%==3 set/a mark="%mark%+1"
if %aeight%==3 set/a mark="%mark%+1"
if %anine%==2 set/a mark="%mark%+1"
if %aten%==3 set/a mark="%mark%+1"
echo %mark%"/10" questions correct.
echo.
echo To see your answers, type 1
echo To go to the main menu, type 2
echo To exit the quiz, type 3
set/p markselection= Make your selection:
if %markselection%==1 goto RESULTONE
if %markselection%==2 goto MAINMENU
if %markselection%==3 goto ENDPROGRAM
:ACCREDITATION
cls
title Accreditation
echo -Information taken from Grade 9 shop question booklet
echo -Software used: Zed (available on chrome web store),
echo Notepad++ (available by google search),
echo Google drive and related services (available online)
echo -Creator: Exalor Stepaniuk (shop class grade censored, 2016/17)
echo.
pause
goto MAINMENU
:ENDPROGRAM
exit
Again, sorry if I did something wrong by dumping the entire script here. I just don't really know what i'm doing.
The root cause of your bug is this line in QUESTIONTEN:
set/p athree=
This looks like a typo in that you meant to set aten instead of athree.
More specifically, since aten was empty, within MARK, the comparison ends up being interpreted like this:
if ==3 set/a mark="[mark value]+1"
Notice that the left operand is empty. The line is being interpreted wrong, and that's why you're getting the error. Changing athree to aten will fix this, but there is a trick to fixing comparisons so that you don't break your script when one of your operands is null. Just put something on both sides. For example, surround your comparators by quotes.
if "%leftoperand%"=="%rightoperand%" ...
Then, even if one or both be empty, it won't terminate your script. It will just look like if ""=="".
Also, a general trick to debugging batch files is to narrow down where errors occur (and why) by putting echo statements, even simple ones, like echo 1 at strategic spots. Then, when you see a 1 in the output, you know that line was executed, and your error is after that line. Once you find the bad line that your script is terminating on, you can echo a copy of it to see what the script is interpreting it as, which will help you figure out the problem.
Like this:
echo if %aten%==3 set/a mark="%mark%+1"
if %aten%==3 set/a mark="%mark%+1"
I hope that helps.

make a bat file that asks what game I want to play

My idea was to have it start when the computer boots and then ask me what game do I want to play. That's simple but I want to be able to answer different answers like: Is the input like CS:GO,cs,csgo,counter strike, and so forth and, here's how I tried to do it=
if %game%==1,CS:GO,cs:go,csgo,"Counter Strike","counter strike" goto cs
But as you probably know, it did not work. so the question is how to make it so that "%game%" can be a lot of different things and still goes to the same thing without having to do multiply if %GAME%==...?
and here's the whole code if you want to see it=
#echo off
color a
cls
:start
echo what game do you want to play?
echo 1/"CS:GO"? -"Counter Strike: Global Ofensive"
echo 2/"H&G"? -"Heros & Generals"
echo 3/"P2"? -"Portal 2"
echo 4/"UT"? -"Unturned"
echo 5/"LO"? -"Loadout"
echo 6/"DAB"? -"Double Action Boogaloo"
set /p game=vwhat game?:
if %game%==1,CS:GO,cs:go,csgo,"Counter Strike","counter strike" goto cs
pause
goto start
:start
echo what game do you want to play?
echo 1/"CS:GO"? -"Counter Strike: Global Ofensive"
echo 2/"H&G"? -"Heros & Generals"
echo 3/"P2"? -"Portal 2"
echo 4/"UT"? -"Unturned"
echo 5/"LO"? -"Loadout"
echo 6/"DAB"? -"Double Action Boogaloo"
set /p game=what game?:
echo /1/CS:GO/csgo/Counter Strike/ |find /i "/%game%/">nul && goto cs
rem other games here...
pause
goto start
/i makes the findcase insensitive, so it will find CSGO, CsGo, cSgO,...
&& works as "if previous command (find) was successful, then..."

I need a way to prompt a user for an input using batch

I noticed a post on how to make a batch that opens another batch upon an input. However, I need a way that will make the code pause until the correct input is entered, then continue.
So for example, the code would ask what is the access code?
Then the user would input the correct code, for example 123.
Then the code would say "Welcome!"
Then it would execute another question like "What do you want to do today?"
There would be a list of options:
A. Game
B. Browse
C. Nevermind
The user would in put a, b, or c and the script would start either a game or web browser. If the user selected C, then it would exit.
Thanks for the help!
#echo off
echo Welcome!
echo What do you want to do today?
echo.
echo A. Game
echo.
echo B. Browse
echo.
echo C. Nevermind
echo.
choice /C:ABC /N /M "Enter your choice: "
if "%errorlevel%"=="1" goto :game
if "%errorlevel%"=="2" goto :browse
if "%errorlevel%"=="3" goto :nevermind
goto :error
I think a little bit modified version of code should work just fine.
#Echo off
:Start
cls
echo Welcome !
echo To Greet press one.
echo For Goodbye press two.
echo To Abort press 3
ECHO.
ECHO.
SET /p Option=Choice:
if "%Option%"=="1" GOTO Sub_MenuA
if "%Option%"=="2" GOTO Sub_MenuB
if "%Option%"=="3" GOTO Sub_MenuC
if "%Option%"=="quit" GOTO EOF
Goto Start
:Sub_MenuA
echo Hi There!
pause
Goto Start
:Sub_MenuB
echo tatas !
pause
Goto Start
:Sub_MenuC
echo Aborted
Pause
Goto Start
:EOF

Resources