Files not waiting for each other

Posted by Sunny on Stack Overflow See other posts from Stack Overflow or by Sunny
Published on 2013-11-02T07:07:52Z Indexed on 2013/11/02 9:54 UTC
Read the original article Hit count: 378

I have two batch files as follows in which file2.bat is dependent on file1.bat's output:

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 

file1.bat usually takes 60 sec to complete its execution.

In master.bat file i am calling above two files as:

call file1.bat
call file2.bat

but file2.bat is not waiting for file1.bat to complete its execution.

Even , i tried to call file2.bat within file1.bat as below but still its not waiting for file1.bat to get completed:

@ECHO OFF
setlocal enabledelayedexpansion
SET "keystring1="
(
 FOR /f "delims=" %%a IN (
  Source.txt
  ) DO (
  ECHO %%a|FIND "HsvDataSource.exe" >NUL
  IF NOT ERRORLEVEL 1 SET keystring1=%%a
  FOR %%b IN (EUHFMPROD USHFMPROD TL2TEST GSHFMPROD TL2PROD GSARCH1213 TL2FY13) DO (
   ECHO %%a|FIND "%%b" >NUL
   IF NOT ERRORLEVEL 1 IF DEFINED keystring1 CALL ECHO(%%keystring1%% %%b&SET    "keystring1="

  )))>file2.txt

GOTO :EOF

call file1.bat

I also tried below start option, but no effect.:

start file1.bat /wait
call file2.bat

Not getting ..why its happening..?

© Stack Overflow or respective owner

Related posts about batch-file

Related posts about batch-processing