Page 1 of 1

Need to know the status of BAT file execution

Posted: 07 Jul 2010 06:56
by paulwintech
Hi,

I have a batch file which executes the command(for eg:- CVS update). My question is as follow

1. How to know that CVS update command in bat file is executed successfully.

2. After successful execution only - it need to execute the next line.

3. Whether success OR failure a log file need to be created in specified path.

4. In that log path i need to write details like 'date/time and result of my batch command"

5. I call this batch file from a utility, In that utility i have several batch files waiting to be executed subsequently. After the successful execution of batch1 - It then need to execute the next batch2. Batch1 may take some time, Till then batch2 should wait and then after completion of batch1 it should execute batch2.

Please help in this queries... I have googled and found nil result relate to my issue.

Thanks
Paulwintech

Re: Need to know the status of BAT file execution

Posted: 07 Jul 2010 14:21
by avery_larry
Well, each individual program will *typically* return an errorlevel. You can test for that:

Code: Select all

@echo off
c:\myotherprogram.exe
if errorlevel 255 goto :error255
if errorlevel 100 goto :error100
if errorlevel 10 goto :error10
if errorlevel 1 goto :error1
echo if you get here, then errorlevel is 0
echo which usually means success
echo Do whatever other code you want for success.
goto :eof

:error255
echo Errorlevel 255 or greater
goto :eof

:error100
echo Errorlevel 100 - 254
goto :eof

:error10
echo Errorlevel 10-99
goto :eof

:error1
echo Errorlevel 1-9
goto :eof


*Typically* a program will return errorlevel 0 for success, and errorlevel anythingelse for some type of failure. Some programs will have different errorlevels which correspond to different types of failure. But this is all dependent on that other program. You'll need to figure that out.