Page 1 of 1

When m key pressed, goto

Posted: 06 Mar 2010 13:36
by BAT Beginner
I really want a script that when you press the m key, it goes to a certain place in the BAT script.

Re: When m key pressed, goto

Posted: 06 Mar 2010 13:53
by aGerman
Could you explain what you wanna do?
BTW: Is choice.exe available for you?

Re: When m key pressed, goto

Posted: 06 Mar 2010 19:46
by BAT Beginner
@echo off
cls
:menu
echo Hello
if %password%==password (
doing something and looping
if m key pressed goto menu
)
Something like above.
"Is choice.exe available for you?"
Yes, yes it is.

Re: When m key pressed, goto

Posted: 07 Mar 2010 08:32
by aGerman
Hmm, try something like that:

Code: Select all

@echo off &setlocal

:menu
set "password="
set /p "password=Enter your password: "
cls
if "%password%"=="password" (
  set /a n=0
  goto loop
)
goto menu

:loop
echo.
echo You logged in successfully.
echo This is loop %n%.
set /a n+=1
echo.
REM old choice.exe:
:: choice /n /c:lm "(l)oop again, show (m)enu: "
REM new choice.exe:
choice /n /c "lm" /m "(l)oop again, show (m)enu: "
set /a x_diff=0
cls
if errorlevel 2 goto menu
goto loop


Regards
aGerman