0

For example:

if "%input%" contains "Hello"

I've also tried:

if "%input%" neq "Hello" (
    echo example
)

But whenever I press ENTER, or type anything, I didn't set here, it just returns example

Any way to fix this?

Compo
  • 36,585
  • 5
  • 27
  • 39
callus
  • 3
  • 3
  • yes thank you dude – callus Aug 06 '21 at 20:49
  • `IF /I "%input%" == "Hello"` checks whether the value case insensitively matches the string. `IF /I NOT "%input%" == "Hello"` checks whether the value case insensitively doesn't match the string, `IF /I "%input%" == "%input:Hello=%"` checks whether the value did not contain the substring, and of course `IF /I NOT "%input%" == "%input:Hello=%"` checks whether the value contains the substring. Please note however that the methodology may not work as simply with all characters, so it is safest used for just alphanumeric substrnigs. – Compo Aug 06 '21 at 20:59
  • *if "%input%" contains "Hello"* translates into `echo/%input%|findstr /i "Hello" && echo yes || echo no` – Stephan Aug 07 '21 at 09:17

0 Answers0