Jérôme
Jérôme

Reputation: 27027

dos batch : using double quotes with IF

I have a DOS-batch like this :

@echo off
if "%1" == "%2" GOTO next
echo different
goto end
:next
echo same
:end

Are the double quotes surrounding %1 and %2 necessary ? In which case are they useful ?

Upvotes: 1

Views: 550

Answers (1)

harper
harper

Reputation: 13690

You need an expression before and one after the ==. If %1 or %2 is empty than you would get an syntax error.

Upvotes: 1

Related Questions