views:

1173

answers:

3
+1  Q: 

Batch not equals

According to this, !==! is the not-equal string operator. Trying it, I get:

C:\> if "asdf" !==! "fdas" echo asdf
!==! was unexpected at this time.

What am I doing wrong?

+2  A: 

try

if NOT "asdf" == "fdas" echo asdf

Frank Bollack
+1  A: 

Try:

if not "asdf" == "fdas" echo asdf

That works for me on Windows XP (I get the same error as you for the code you posted).

Dominic Rodger
+4  A: 

Use NEQ instead.

if "asdf" NEQ "fdas" echo asdf
demoncodemonkey
this requires command extensions to be turned on (They are by default on 2000+ but can be turned off system wide or as a parameter to cmd.exe) Normally you should turn them on with setlocal, but for a simple if not equal test, just use "if not", it goes back to the good old DOS days
Anders