1.

Solve : IF ELSE command in batch files?

Answer»

Hi All...

I am a NEW bie and have no knowledge on batch files.. plz help me out of this

i write a batch file which checks whether arguements are passed to the batch script as an input or not

like

@echo off
IF "%1"=="" GOTO END ELSE GOTO Syntax
:Syntax
echo SUCCESS
:END
echo failure

pause

when i eecute in commandpromt as call filename.bat
gives me failure
but when i GIVE as call filename.bat HI
gives me success and failure too but i want that as only success .. any trick here please helpQuote from: luckey on October 01, 2007, 01:07:12 AM

Hi All...

I am a new bie and have no knowledge on batch files.. plz help me out of this

i write a batch file which checks whether arguements are passed to the batch script as an input or not

like

@echo off
IF "%1"=="" GOTO END ELSE GOTO Syntax
:Syntax
echo success
:END
echo failure

pause

when i eecute in commandpromt as call filename.bat
gives me failure
but when i give as call filename.bat HI
gives me success and failure too but i want that as only success .. any trick here please help

Your batch file needs changing. When a line is finished, it passes to the next one.

In the "success" situation, it will pass to the the next line. This is the :END label.

This is what I SUGGEST

@echo off
IF "%1"=="" GOTO fail

echo success
goto end

:fail
echo failure

:end
pause




Discussion

No Comment Found