Batch file call sub-batch file to pass n paramenters and return without use of file

Viewed 93196

I looking for a way using windows batch file that call sub-batch file which pass 1-9 parameters and return value (string) without the need of saving the return value into file/etc. The return value I save into variable like did in @FOR /F

I look at

@FOR /F "tokens=*" %%i IN ('%find_OS_version%') DO SET OS_VER=%%i

and

Call function/batch %arg1% %arg2%

I'm not seeing how I can setup to do this

EDIT: dbenham somewhat answer my question. His example was between batch file main part and function. My question was between two different batch files. Base off dbenham answer this is the follow layout.

Main batch file

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
3 Answers
Related