First I think it prudent to show how to do it with IF statements. Batch IF does not support OR logic. The following emulates the OR:
@echo off
setlocal enableDelayedExpansion
set "mode=%~1"
set "aModes= TYPE1 TYPE2 "
set "bModes= TYPE1 TYPE3 "
set "cModes= TYPE3 "
if "!aModes:%mode%=!" neq "!aModes!" echo command A
if "!bModes:%mode%=!" neq "!bModes!" echo command B
if "!cModes:%mode%=!" neq "!cModes!" echo command C
Now for possible alternatives to IF
1) One semi-practical thing I can think of is to use the MODE as a label, but I don't like it. Unnecessary use of CALL can be significantly slower. You must ensure that the MODE values are controlled, otherwise you will get ugly error messages. Also, the commands are replicated in the code since the same MODE runs multiple commands.
@echo off
setlocal
set "mode=%~1"
call :%MODE%
:: remainder of logic
exit /b
:TYPE1
echo command A
echo command B
exit /b
:TYPE2
echo command A
exit /b
:TYPE3
echo command B
echo command C
exit /b
If command A and/or B and/or C is a complicated block of commands, then they could be made into their own labeled subroutine, and CALLed where appropriate. This would prevent replication of the complicated logic.
2) Another possibility is FINDSTR with conditional command execution, but this will be slower than IF, and it is more awkward. The only advantage is it does not require extra variables to implement the OR logic.
@echo off
setlocal
set "mode=%~1"
echo %mode%|>nul findstr "TYPE1 TYPE2" && echo command A
echo %mode%|>nul findstr "TYPE1 TYPE3" && echo command B
echo %mode%|>nul findstr "TYPE3" && echo command C
Note that if your modes were something like BC and ABCD, then the above will not work because BC is contained within ABCD. This could be handled by introducing some brackets.
@echo off
setlocal
set "mode=%~1"
echo {%mode%}|>nul findstr "{TYPE1} {TYPE2}" && echo command A
echo {%mode%}|>nul findstr "{TYPE1} {TYPE3}" && echo command B
echo {%mode%}|>nul findstr "{TYPE3}" && echo command C
Finally, you could use MC ND's idea of a simple macro to make the above look a bit more elegant.
@echo off
setlocal
set "mode=%~1"
set "whenMode=echo {%mode%}|>nul findstr"
%whenMode% "{TYPE1} {TYPE2}" && echo command A
%whenMode% "{TYPE1} {TYPE3}" && echo command B
%whenMode% "{TYPE3}" && echo command C
3) You could get really fancy and use an advanced technique of batch macros with arguments. Here is a good primer to the technology and development of batch macros with arguments.
It takes a significant bit of arcane code to set up the macro, but once defined, it is very easy to use, and extremely fast. The best part is it can be used against any variable. In my example below, I use it with MODE1 and MODE2.
@echo off
setlocal disableDelayedExpansion
set "mode1=%~1"
set "mode2=%~2"
:: define LF as a Line Feed (newline) character
set ^"LF=^
^" Above empty line is required - do not remove
:: define a newline with line continuation
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
:: define a when macro that takes arguments
set when=%\n%
for %%# in (1 2) do if %%#==2 (setlocal enableDelayedExpansion^&for /f "tokens=1*" %%1 in ("!args!") do (%\n%
set "test= %%~2 "%\n%
for /f %%M in ("!%%1!") do (%\n%
if "!test:%%M=!" neq "!test!" (%\n%
endlocal%\n%
endlocal%\n%
(call )%\n%
) else (%\n%
endlocal%\n%
endlocal%\n%
(call)%\n%
)%\n%
)%\n%
)) else setlocal^&set args=
:: ------- End of Initialization ---------------------
(%when% mode1 "TYPE1 TYPE2") && echo command A
(%when% mode1 "TYPE1 TYPE3") && echo command B
(%when% mode1 "TYPE3") && echo command C
(%when% mode2 "TYPE1 TYPE2") && echo command X
(%when% mode2 "TYPE1 TYPE3") && echo command Y
(%when% mode2 "TYPE3") && echo command Z