1.

Solve : Sequential Execution of batch files?

Answer»

Hi,

I want to execute a series of batch files, each accomplishing a different task based on the success of the PREVIOUS one but for some reason the execution is stopping right after the first one in the below code:

Code: [Select]ECHO OFF
REM========================================

REM ====================================================
REM 1) Execute First Batch
REM ====================================================

pushd "D:\temp"
sample1.bat
popd

if %errorlevel% neq 0 (
  echo sample1 failed to execute successfully
  GOTO EXITERROR ) ELSE ( goto step2
)


REM ====================================================
REM 2) Execute Second Batch
REM ====================================================

:step2

pushd "D:\temp"
sample2.bat
popd

if %errorlevel% neq 0 (
  echo test2 failed to execute successfully
  goto EXITERROR ) ELSE ( done
)


REM ==================================
REM ERROR Code
REM ==================================
:EXITERROR
Please can you help?

Thanksyou have to use CALL to execute a batch FILE and have it return to the calling batch; "call sample2.bat" instead of "sample2.bat" for example.Thank you..It works

However when I try to put the error messages in a log file by giving

Code: [Select]SET log=\temp\sample.log
and redirect

Code: [Select]if %errorlevel% neq 0 (
  echo sample1 failed to execute successfully >>%log%
  goto EXITERROR ) ELSE ( echo done >>%log%

I am not seeing the sample.log file in the temp folder. How do I create a common file for log and append it with every message in my bat file?



Discussion

No Comment Found