there is a nice way to build functions in DOS .bat/.cmd script. To modularize some installation scripts, it would be nice to include a file with a library of functions into an .
In the given link there's a script for importing subroutines into the main script.
The syntax is something like:
if not defined _import (
rem OPTIONAL (before the "import" calls):
set "CMD_LIBRARY="
import "[FILE_PATH1]filename1" / "DIR_PATH1"
...
import "[FILE_PATHn]filenamen" / "DIR_PATHn"
import end "%~0"
)
...
Please see this answer.