Windows .bat/.cmd function library in own file?

后端 未结 6 2087
春和景丽
春和景丽 2021-02-05 14:50

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 .

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 15:33

    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.

提交回复
热议问题