If else statement in Batch file

September 10, 2008 at 07:53:59
Specs: Win2003, AMD

Hi,

I want to write a code in batch file.
It is like if else statement.

There are two variables.

Writing in usual language

Say Complete=244,Fail=0

if Complete=244 and Fail=0 means goto Pass
If complete=240 and fail=4 means goto fail

I dont know how to merge to conditions in a if statement.

:pass

Echo load completed succesfully

:Fail

Echo load failed so starting services
Start servies

end

How can i achieve the above in batch file.

Please help me

Regards,
venugopal


See More: If else statement in Batch file

Report •


#1
September 10, 2008 at 10:00:08

The following code translates what you posted into a batch executable script, but your knowledge of scripting looks poor so I can't assure you can achieve a working result.

if %Complete% equ 244 if %Fail% equ 0 (
echo. Load completed succesfully & goto :END
)
if %Complete% equ 240 if %Fail% equ 4 (
echo. Load failed so starting services
Start services
)
:END


Report •

#2
September 11, 2008 at 00:51:02

What about:


IF %COMPLETE%==244 (IF %FAIL%==0 GOTO PASS) ELSE IF %COMPLETE%==240 IF %FAIL%==4 GOTO FAIL

That's all one line.

[edit]
I do realise the message above integrates the whole thing into one small script. Just another option...


Report •

Related Solutions


Ask Question