padma sri
padma sri

Reputation: 119

Batch Script - Does the below script gives correct output

Am trying to write IF-ELSE condition in batch script with functions. it not working. Can you help me if I am anywhere wrong here. Its working for IF condition goes well. But ELSE not working it was showing below error: 'else' is not recognized as an internal or external command, operable program or batch file.

set A=2
if %A%==1 GOTO:GOOD
else GOTO:BAD

:GOOD 
echo All is well
EXIT /B 1

:BAD
echo Wrong
EXIT /B 1

Upvotes: 1

Views: 33

Answers (1)

jdigital
jdigital

Reputation: 12276

Try this:

set A=2
if %A%==1 ( 
    GOTO:GOOD
) else (
    GOTO:BAD
)

:GOOD 
echo All is well
EXIT /B 1

:BAD
echo Wrong
EXIT /B 1

Upvotes: 1

Related Questions