Call a subroutine in a batch from another batch file

前端 未结 4 1523
太阳男子
太阳男子 2020-12-06 13:46

file1.bat:

@echo off
 :Test
echo in file one
call file2.bat (Here i want to call only Demo routine in the file2.bat)

file2.bat:

<         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-06 14:27

    the file with subroutines must look like:

    @echo off
    call :%*
    exit /b %errorlevel%
    
    :hello
    echo in hello
    exit /b 0
    :Demo
     echo in Demo with argument %1
     exit /b 0
    

    then from the other file you can call it like

    call file2.bat demo "arg-one"
    

提交回复
热议问题