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
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
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...
Summary: Hi, I am writing a batch file. I am accepting the parameter from user and trying to display message depending on the parameter entered. Here is the batch file content @ECHO OFF SET /P USERPARM=Enter t...
Summary: How do i end an if/else statement, in C, in the middle of a program if a variable is incorrect without using a goto statement or another return 0 statement? ...
Summary: Hi These subroutines may be useful for calculating date issues in Batch File coding. The sub-rountines use variables a-f so best to not to use them in your calling code. Main varables returned are... ...