Solved will this if-else work???

June 28, 2012 at 07:54:09
Specs: Windows XP
ECHO Checking the log file for errors...
FINDSTR /c /m "RC (return code) = 0" "%ddlDir%\%filenm%_Log.txt"
IF %errorlevel% neq 0 (
ECHO Deployment was not successfull. Errors were found!
ECHO Emailing the admin...
ECHO Press ENTER to exit the command window
start fail_mail_DEV.vbs
pause > nul
)ELSE(ECHO Emailing the admin...
start success_mail_DEV.vbs
ECHO Press ENTER to exit the command window
pause > nul

See More: will this if-else work???

Report •

July 7, 2012 at 20:44:43
It looks like it should work. The findstr argument looks a little off to me but I don't really use it a ton other than for standard stuff so I may be off.
If it isn't working try ending your first if statement with a bracket and then on a brand new line, just type in: if else ("code")
That shouldn't make a difference but honestly batch programming is so picky with even the littlest things sometimes that any little change could work.

Report •

July 7, 2012 at 23:40:28
✔ Best Answer
no, i don't think. because /c wants an immediate argument (a literal expression):
findstr /c:"this text to find" targfile
in this case:
FINDSTR /m /c:"RC (return code) = 0" "%ddlDir%\%filenm%_Log.txt"
consult: findstr /?
for all findstr options /switches. I'll admit, they can be confusing, so... experiment!

Report •

Related Solutions

Ask Question