1

So I wanted to create a code in batch that can make both C and c valid to go to :color This is the only way I was able to do it, but I was wondering if there is a more "efficient" way.

I'm new to coding and the programming world, so I'm not a Batch expert.

echo Choose again (C) or go back to Main Menu (M)?
set /p choice=Your choice: 
if %choice%==C goto :color
if %choice%==c goto :color
if %choice%==M goto :menu
if %choice%==m goto :menu

my idea was something like

if %choice%==C,c goto :color

or

if %choice%==C& c goto :color

I will appreciate any and all help. Thanks in advance

lmujo
  • 13
  • 3

2 Answers2

1

read HELP IF ... the /I switch, if specified, says to do case insensitive string compares....

and try at the command line

IF /I %choice%==m @echo Menu
PA.
  • 28,486
  • 9
  • 71
  • 95
0

In addition to @PA.'s answer, batch doesn't support implicit logical operators (AND/OR) but you can emulate them as described in: How can I use multiple conditions in “If” in batch file?

Taking a look into powershell may be a good idea if you want to go further with logical programming while keeping the familiar feel of the cmd environment.

Community
  • 1
  • 1
CalebB
  • 597
  • 3
  • 17
  • Thank you for the link, it will certainly help me in the future, and I have got some ideas how to implement it into my current project. – lmujo Dec 15 '14 at 21:40