-1

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
breq
  • 1
  • 2
  • 1
    I suggest to read my answer on [How to stop Windows command interpreter from quitting batch file execution on an incorrect user input?](https://stackoverflow.com/a/49834019/3074564) and [Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files](https://stackoverflow.com/a/47386323/3074564). – Mofi May 28 '22 at 15:56

1 Answers1

0

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.

Magoo
  • 77,302
  • 8
  • 62
  • 84