Computing.Net > Forums > Programming > If else statement in Batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

If else statement in Batch file

Reply to Message Icon

Name: venugopal_p01
Date: September 10, 2008 at 07:53:59 Pacific
OS: Win2003
CPU/Ram: AMD
Product: NA
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 10, 2008 at 10:00:08 Pacific
Reply:

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


0

Response Number 2
Name: Judago
Date: September 11, 2008 at 00:51:02 Pacific
Reply:

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...


-1

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: If else statement in Batch file

IF ELSE Error in Batch file www.computing.net/answers/programming/if-else-error-in-batch-file/15450.html

Ending an if/else statement www.computing.net/answers/programming/ending-an-ifelse-statement/7973.html

Date Routines in Batch Files www.computing.net/answers/programming/date-routines-in-batch-files/15590.html