Menu Based Batch - How to Program Menus

preview_player
Показать описание
RATE - COMMENT - SUBSCRIBE

Facebook:

Patreon:
Рекомендации по теме
Комментарии
Автор

Tip: You can type pause>nul
And it won’t show press any key to continue...

koskelii
Автор

thanks so much synthetic programing i have bin searching for week on how to program and i got nothing but i really like batch file and when i saw your playlist i had to watch and learn from them now just from 10 videos i can make menu based games on batch files PS love your videos

mysticj
Автор

Batch was what got me into coding 3 years ago, now I’m currently learning HTML, css, and js.

potatomemes
Автор

@echo off
:top
Echo Thank you very much!
Goto top

Farsmezan
Автор

Thank you man you are good teacher. I learned in my first watching. I will do a bassic program with this information :D

bedirhanozcan
Автор

Jesus, I used to know this way way back. It's coming back to me now. It's fun to make batch files, I actually made an adventure game this way :p

vBDKv
Автор

What about this?

@echo off
:menu
echo [1] Enter in menu 1
echo [2] Enter in menu 2
set /p answer="Number: "
if %answer%==1 goto 1
if %answer%==2 goto 2

:1
echo wrong one.
pause>nul
goto menu

:2
echo hi
pause>nul
goto menu

goto error
:error
cls
Unknown command.
Try again.
ping localhost -n 4 >nul
goto menu

regdel
Автор

You don't need to use %x% you can just do !x!.
And you dont need to do: set /p x="Enter: " You can just do set /p x=Enter:
And if you have: if !x! == y ( goto z) you can do if !x! == y goto z.

Just some tips to make the code a bit easier to read/write.

eyewarsx
Автор

"When it quits out its stupid"






Solid point lel

morkthecar
Автор

Feels like everyone forgot BATCH. It's free, installed in even Win10. Why write pages of complex PowerShell when you can get away with something easy? BATCH still has value.

Jaiven
Автор

here's another one
@echo off
title batch
:START
echo (and on you know how to make it fancy)
echo (m)enu
echo (t)est
echo (e)xit
echo (p)ing
echo (and on and on)
echo pick a letter to proceed
choice /C:MTEP /N /M
goto :choice-%ERRORLEVEL%
:choice-1
cls
echo this is just a menu..
pause
goto :START
:choice-2
cls
echo test
pause
goto :START
:choice-3
exit
:choice 4
cls
pong
pause
goto :START











using the choice command makes it alot easier to use and it will require less code, this is only compatable with one letter,
you can find more information on sites like computerhope or you can ask questions to the stackoverflow community glad if i could help you and good luck with your programming route!

NH-gevz
Автор

pause >nul (hides press any key to continue.)

DataStream
Автор

also, i think you can add :
else (
cls
echo wrong input!

pause
goto :menu
)
That means, when the input will be different then 1 or 2, it will say -- wrong input, and return you back to choose.

dantex_remake
Автор

I can give you somethings more simple if you want to (exemple) don't want that the user is Pressing any key to continu just type this command, replace the "pause" by ping localhost -n "number of second" > nul
for 1 sec ->
ping localhost -n 1 > nul

stravosky
Автор

thank you so much, im making a program for a thing and your video help me (my english is very bad) im from brazil, thx man for this video!

scarzito
Автор

I did it like you, basically copied it, but when i hit the number it just closes

greenlishtv
Автор

Revised code:


@echo off
color a
:Main
cls
echo Enter 1 for menu 2:
echo.
echo Enter 2 for menu 3:
echo.
set /p ans="Enter Number:"
IF %ans%==1 GOTO a
IF %ans%==2 GOTO b


:a
cls
echo.
echo You are at menu 1 :D
echo.
echo Press any key to return to main menu.
TIMEOUT /T 2 >nul
pause >nul
GOTO Main



:b
cls
echo.
Echo you are at menu 2 :D
echo.
TIMEOUT /T 2 >nul
echo Press any key to return to main menu.
pause >nul
GOTO Main

DataStream
Автор

Your code is pretty basic bro. You could use something a bit more complex and not have to reuse code, eg if you have more than 2 entries in your menu are you going to repeat the same lines again?

ndog
Автор

How come the window closes after hitting enter following typing the number?

fgcapps
Автор

The menu errors and exits when you press enter.... I've been browsing the internet on how to create a non errorless menu in batch

adeochuzho