Batch file call sub-batch file to pass n paramenters and return without use of file

后端 未结 3 1175
死守一世寂寞
死守一世寂寞 2020-12-13 09:29

I looking for a way using windows batch file that call sub-batch file which pass 1-9 parameters and return value (string) without the need of saving the return value into fi

3条回答
  •  一生所求
    2020-12-13 10:09

    Small TIP

    Setlocal EnableDelayedExpansion
    IF 1==1 (
        CALL :LABEL
        echo 1: %errorlevel%
        echo 2: !errorlevel!
    )
    echo 3: %errorlevel%
    
    :LABEL
    EXIT /B 5
    

    Output will be:

    1: 0
    2: 5
    3: 5
    

    EnableDelayedExpansion allows you to use !var_name! to expand var at execution time, rather then parse time.

提交回复
热议问题