Search code examples
batch-filecmdsql-job

An sql job doesn't wait an exe file, which was run from a batch file


This is the code of my bat file which I call from my first SQL job step.

@echo off

    REM %year% %month% calculation
    .....   

    start LongWork.exe %year% %month% 

Second SQL job step calls a SecondLongWork.exe which uses the results of the LongWork.exe. The problem is that the second step runs immediately after .bat ends its work. It does not wait while LongWork.exe end its work. How can I change this behavior?


Solution

  • I could reproduce such a problem at the command prompt: using start will open a new cmd window, and the original one has a new prompt (doesn't wait till the started app returns), while without start the prompt is hanging and waiting for the app to return. So what is the reason for using start? In that case your .bat file is proceeding to the next statement or if there's no more returns right after the app starts.