【发布时间】:2020-06-15 14:50:22
【问题描述】:
我想开始一个下标来为我计算一些东西,如果它完成了以某种方式返回值。
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 函数,这不是我需要的(在我看来)。
【问题讨论】:
-
关键是你想“并行”做(而你的
foo.bat做一些“有用”的事情)。这意味着您有两个无法(通过设计)相互通信的进程。最好的选择是使用文件。 -
如果是这样的话,那就太不幸了。但是游戏或其他程序是如何做到的。我敢打赌他们没有制作文件以便线程可以通信......
-
他们不使用
cmd.exe... -
好吧,只要你没有准确描述你想要达到的目标,没有人能真正帮助你……
标签: windows batch-file cmd parallel-processing parameter-passing