Solved how to use if not command twice in same line?

February 15, 2014 at 19:31:02
Specs: Windows 7
Hi, How do i make 2 "if not" commands in the same line work. With this current code, the batch would go to :pos, but supposing I were to change the %i% variable from ww to www, it should go to :neg because one of the 2 conditions is not met.. I tried to put "and" in the middle of the 2 "if not" conditions but that makes the batch crash. Thanks.

Batch file:

set i=ww
set p=ee

if not %i%==ww if not %p%==ee goto neg
goto pos


echo correct

See More: how to use if not command twice in same line?

Report •

February 16, 2014 at 08:52:57
✔ Best Answer
First of all you have to revise your logic since to miss the first OR the other condition sets up an OR boolean operator, i.e.

if not %i%==ww goto :neg
if not %p%==ee goto :neg

on the contrary if BOTH the conditions must be satisfied, then you get an AND

if not %i%==ww if not %p%==ee goto :neg

Report •
Related Solutions

Ask Question