1.

Solve : Wait for command to complete before contining batch file?

Answer»

I have created a batch file with the following syntax

call c:\maxl\batch\inflation.bat

@echo off

:begin
febootimail -FROM [emailprotected] -TO [emailprotected] -MSG "Inflation Cubes are complete. Please do not respond to this message as it is sent from an unmonitored account." -SUBJECT "Inflation Cubes complete" -SMTP THCNOTES

if not errorlevel 5 goto end
echo Couldn't connect to server. Trying again...
goto begin

:end
echo End of batch program.

the first line calls another batch file which runs an essbase maxl script in a dos window, the problem is that when it runs the script it calls the 2nd batch file and that closes as soon as it has called the maxl script, I need a way to make the called batch file wait until the maxl script has run its course , is there anyway to make it wait until the script has runIf you KNOW how long it takes for that process to complete you can use a number of ways to make it COUNT x number of seconds before continuing.

Would a preset time delay work for you?not really, I need to know the time it is complete and then an email sent, the process could take 30 minutes to an hour BASED on server usage
i tested the following code, and call statement does calling another batch, and return to the caller once finished.
Code: [Select]@echo off
(
echo echo inflation bat start
echo ping 127.0.0.1 ^>nul
echo echo inflation bat finish
)>#.bat

call #.bat
echo return from call statement

so i suspect "inflation.bat" contain some command that run windows program in its own thread/process. or it MIGHT contain nt dos command such as "start","%comspec%", or "cmd" which create a new instance.How about changing your CALL batch file command to:

Code: [Select]start /wait cmd /C "c:\maxl\batch\inflation.bat"
@echo off
(
echo echo inflation bat start
echo ping 127.0.0.1 ^>nul
echo echo inflation bat finish
)>#.bat

call #.bat
echo return from call statement

this command is rewriting the inflation.bat file to read

echo echo inflation bat start
echo ping 127.0.0.1 ^>nul
echo echo inflation bat finish
Quote from: nigelben on March 09, 2009, 09:16:56 AM

this command is rewriting the inflation.bat file to read



it's just an example to proof that call statement does wait for a batch file to finish EXECUTING before returning.
if you can post the code of inflation.bat, maybe someone can help you.I think the code in Reply #4 should work for any code in the "inflation.bat" file.


Discussion

No Comment Found