Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Adrianvdh
- Posts: 177
- Joined: 16 May 2013 13:00
#1
Post
by Adrianvdh » 05 Oct 2013 03:29
Hi everyone.
I only noticed this problem yesterday and tried to fix it. The problem did not occur at all.
Code: Select all
choice /C 12b /N /M "Make your selection: "
if errorlevel 3 goto menu
if errorlevel 2 goto test1
if errorlevel 1 goto test2
I have no idea why it won't work any more? ANy help?
Thanks
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 05 Oct 2013 04:17
It works here. *shrug*
Code: Select all
@ECHO OFF
choice /C 12b /N /M "Make your selection: "
if errorlevel 3 echo goto menu
if errorlevel 2 echo goto test1
if errorlevel 1 echo goto test2
%0
pause
-
aGerman
- Expert
- Posts: 4743
- Joined: 22 Jan 2010 18:01
- Location: Germany
#3
Post
by aGerman » 05 Oct 2013 04:31
Yes works for me too. Perhaps a problem with the context of that code snippet (that you didn't post though).
Regards
aGerman
-
Adrianvdh
- Posts: 177
- Joined: 16 May 2013 13:00
#4
Post
by Adrianvdh » 05 Oct 2013 05:39
How can I fix this? CMD.exe is acting weird, all my code doesn't really work now. (Just discover 10 min ago)
Would I need to fix a reg item or something?
-
aGerman
- Expert
- Posts: 4743
- Joined: 22 Jan 2010 18:01
- Location: Germany
#5
Post
by aGerman » 05 Oct 2013 05:45
First try
Code: Select all
@echo off &setlocal
choice /C 12b /N /M "Make your selection: "
if errorlevel 3 goto menu
if errorlevel 2 goto test1
if errorlevel 1 goto test2
:menu
echo menu
pause
goto :eof
:test1
echo test1
pause
goto :eof
:test2
echo test2
pause
goto :eof
If you enter b it should jump to :menu, if you enter 2 it should jump to :test1 and if you enter 1 it should jump to :test2 (in order you specified it). If this doesn't work reboot your machine before you try to do any further actions
Regards
aGerman
-
aGerman
- Expert
- Posts: 4743
- Joined: 22 Jan 2010 18:01
- Location: Germany
#7
Post
by aGerman » 05 Oct 2013 05:58

The name of your batch file is choice.bat, isn't it?
N E V E R call a batch file the same as one of the commands it contains!
Regards
aGerman