When m key pressed, goto

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BAT Beginner
Posts: 16
Joined: 29 Jan 2010 17:19

When m key pressed, goto

#1 Post by BAT Beginner » 06 Mar 2010 13:36

I really want a script that when you press the m key, it goes to a certain place in the BAT script.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: When m key pressed, goto

#2 Post by aGerman » 06 Mar 2010 13:53

Could you explain what you wanna do?
BTW: Is choice.exe available for you?

BAT Beginner
Posts: 16
Joined: 29 Jan 2010 17:19

Re: When m key pressed, goto

#3 Post by BAT Beginner » 06 Mar 2010 19:46

@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.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: When m key pressed, goto

#4 Post by aGerman » 07 Mar 2010 08:32

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

Post Reply