如何批量进行并行处理?

时间:2020-06-15 14:50:22

标签: windows batch-file cmd parallel-processing parameter-passing

我想启动一个下标来为我计算一些东西,并在完成后以某种方式返回该值。

foo.bat:

@echo off
start bar.bat 2 3
::This foo.bat does something and after a while it waits for the calculated value.
set result=//somehow return the value
echo %result%
pause
exit

bar.bat:

@echo off
set int1=%1
set int2=%2
set /a result=%int1%+%int2%
::somehow send the result to the running foo.bat
exit

我试图问here这个问题,但是我被三个人重定向到了call函数,这不是我所需要的(我认为)。

1 个答案:

答案 0 :(得分:0)

尝试:

主要批处理文件

CALL sub_batch_file.bat  return_here "Second parameter input"

REM echo is Second parameter input
ECHO %return_here%
REM End of main-batch file

sub_batch_file.bat

@ECHO OFF
SETLOCAL

REM ~ removes the " "
SET input=%~2
(
    ENDLOCAL
    SET %1=%input%
)
exit /b
REM End of sub-batch file