我有两个批处理文件,如下所示,其中file2.bat取决于file1.bat的输出:
文件1.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
文件2.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通常需要 60 秒才能完成执行。
在master.bat文件中,我将上述两个文件称为:
call file1.bat
call file2.bat
但file2.bat不等待file1.bat完成其执行。
甚至,我尝试在file1.bat中调用file2.bat,如下所示,但它仍然没有等待file1.bat完成:
@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
我也尝试了以下启动选项,但没有效果:
start file1.bat /wait
call file2.bat
没有得到..为什么会发生..?