0

I tried the following command.

@echo off
set /a var1=2
set /a var2=4
if %var1%<%var2%
echo yesss

But am getting the following error.

2< was unexpected at this time.

Please can someone assist

2 Answers 2

1

You need to make a couple of changes:

  • Use the LSS operator rather than <
  • Put the if statement on one line

So your script will look like this...

@echo off
set /a var1=2
set /a var2=4
if %var1% LSS %var2% echo yesss
0

I ended up achieving the result you wanted by using:

@echo off
set /a var1=2
set /a var2=4
if %var1% LSS %var2% echo yes

There is a helpful post relating to the comparative operators here.

EDIT

Just saw Richard beat me to it. Still the link should be a good reference!

0

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