如何进行批处理的并行处理?

问题描述 投票:0回答:1

我想启动一个子标来为我计算一些东西,如果完成了就以某种方式返回值。

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

我想问这个问题 此处 但我被三个人重定向到调用函数,这不是我需要的(在我看来)。

windows batch-file cmd parallel-processing parameter-passing
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.