1.

Solve : press 1 to exit, press 2 to continue!??

Answer»

How could you make a batch file that would "goto" a label if a certain key is pressed?
(I am doing this for making backups. I am going to make it so I can choose to make backups of different things) :-/Code: [Select]:begin
set /p var=Type 1 or 2>
If '%var%'=='1' GOTO 1
If '%var%'=='2' GOTO 2

ECHO Incorrect answer
GOTO begin

:1

:2thanks!It doesn'tseem to be working! :-/ :-?Try adding this right above the "set /p var":

Code: [Select]set var=
so it should read

Code: [Select]@echo off
:begin
set var=
set /p var=Type 1 or 2:
If '%var%'=='1' GOTO 1
If '%var%'=='2' GOTO 2

ECHO Incorrect answer
GOTO begin

:1

:2
Copy that into notepad and save it with a .bat extension. Find cool simple menu here: http://dostips.cmdtips.com/DtTipsMenu.php

Consists of the generic main loop that parses the batch file itself for menu labels:

Code: [Select]:menuLOOP
echo.
echo.= Menu =================================================
echo.
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~F0""') do echo. %%B %%C
set choice=
echo.&set /p choice=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menu_%choice%
GOTO:menuLOOP
Then you can add self descriptive menu functions as code blocks like this:

Code: [Select]:menu_1 Do some copy
echo.do some copy
GOTO:EOF

:menu_2 Do some more
echo.do some more
GOTO:EOF

:menu_Q Quit
echo.bye bye
GOTO:EOF

Would show the FOLLOWING menu when running the batch:

= Menu =================================================

1 Do some copy
2 Do some more
Q Quit

Make a choice or hit ENTER to quit:


Enjoy



Discussion

No Comment Found