I need to check if %test% is not equal to Y or N, how can I do that?
set /p test=
if /i %test% equ Y goto y
if /i %test% equ N goto n
I need to check if %test% is not equal to Y or N, how can I do that?
set /p test=
if /i %test% equ Y goto y
if /i %test% equ N goto n
if the value supplied does not pass the tests, then it must be not-(y,Y,n,N) so batch simply proceeds to the next instruction. No specific test is required.
But - please consider choice which is designed for this task. Use the search facility for [batch-file] choice eg Gerhard's example or see the documentation - choice /? from the prompt.
In comparisons, use if "thing1" == "thing2" ... to avoid problems caused by spaces in thing1/2.