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
Need to know the status of BAT file execution
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Need to know the status of BAT file execution
Well, each individual program will *typically* return an errorlevel. You can test for that:
*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.
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.