1

When using the batch and comparing two strings and comparing all available choices is done like this if /I %variable%==Something ( echo wuhu ) But what i want to do is have a "if not" to all types of one specific string, this should be done like. if not /I %variable%==Something ( echo Does not work )

But as far as i can see this does not work. Is there any way to do it without using for loops in batch?

1 Answer 1

3

The switch /i is related to the command IF, whereas not is a part of the expression.

The correct syntax is:

if /I not "%variable%"=="Something"

P.S. The quotes are added for reliability to handle a possibly empty variable.

1
  • thanks, were doing something wrong inside the if sentence to and missread the "great" error message to batch :)
    – Nyranith
    Aug 3, 2015 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.