Reputation: 8312
I have a master.bat file, which contains:
call file1.bat
call file2.bat
I want file2.bat should not start run until file1.bat completes its execution and generates the output, but in my case file2.bat runs without waiting for file1.bat to complete its execution.
Execution time of files are as follows:
file1.bat= 70 sec
file3.bat= 20 sec
EDIT1
Contents of both batch files are:
file1.bat
@ECHO OFF
setlocal enabledelayedexpansion
SET "keystring1="
(
FOR /f "delims=" %%a IN (
Source.txt
) DO (
ECHO %%a|FIND "Appprocess.exe" >NUL
IF NOT ERRORLEVEL 1 SET keystring1=%%a
FOR %%b IN (App1 App2 App3 App4 App5 App6 ) DO (
ECHO %%a|FIND "%%b" >NUL
IF NOT ERRORLEVEL 1 IF DEFINED keystring1 CALL ECHO(%%keystring1%% %%b&SET "keystring1="
)))>result.txt
GOTO :EOF
file2.bat
@echo off
setlocal enabledelayedexpansion
(for /f "tokens=1,2" %%a in (memory.txt) do (
for /f "tokens=5" %%c in ('find " %%a " ^< result.txt ') do echo %%c %%b
))> new.txt
Upvotes: 0
Views: 209
Reputation: 1304
REM File1.bat
REM DO YOUR FILE STUFF
Call file2.bat
and then
REM File2.bat
REM DO YOUR FILE STUFF
Call file3.bat
and theenn
REM File3.bat
REM DO YOUR FILE STUFF
REM Done? or call next file to run
Upvotes: 1
Reputation: 48914
Running another bat / cmd script using "call" actually does wait for that process to finish before going to the next statement. So, there is something else going on within your "file2.bat", or whatever it calls, that is allowing part of that process to continue while the main process believes file2.bat has completed.
You could try using the "Start" command which lets you specify whether or not to wait until whatever you "start" finishes before moving to the next line. By default it goes to the next line without waiting for its process to complete, but you can specify "/wait" and it will not continue until its process has finished. Type "help start" at the DOS / Command prompt for details.
Note: it is usually best to use the "cmd" extension on scripts instead of "bat" as "cmd" scripts always run in a 32-bit space but "bat" scripts sometime run in a 16-bit space.
Upvotes: 1