Depending on setup, you can make functions external files, or internal in the script.
https://stackoverflow.com/questions/11419046/how-do-i-return-a-value-from-a-function-in-a-batch-file
External CMD Func:
@ECHO OFF set %1=WIN10
Call Func:
set myvar= echo %myvar% call C:\tmp\test.cmd myvar echo %myvar%
Inside Script Example:
@echo off set myvar= echo %myvar% call :myfunction myvar echo %myvar% :myfunction set %1=filled EXIT /B