Functions can work with return values by simply passing variables names which will hold the return values when a call is made to the function as shown below
Call :function_name value1, value2… valuen
The return values are set in the function using the set command and the tilde(~) character along with the positional number of the parameter.
Following example shows how a function can be called with return values.
@echo off SETLOCAL CALL :SetValue value1,value2 echo %value1% echo %value2% EXIT /B %ERRORLEVEL% :SetValue set "%~1 = 5" set "%~2 = 10" EXIT /B 0
The above command produces the following output.