Check if label exists cmd

前端 未结 5 824
深忆病人
深忆病人 2021-01-03 06:29

I wonder is there any way to check that if a label exist in a batch file?

If %input%=ABC (  
  If Label ABC Exists (
    Goto ABC
  )
)

How

5条回答
  •  鱼传尺愫
    2021-01-03 06:59

    Try the following code:

    echo off
    set "label=sub"
    REM next line to reset errorlevel to zero:
    (call )
    call :%label% 2>nul || (echo %label% not found & exit /b 1) 
    echo back from %label%
    Exit /b 0
    
    :sab
    echo here we are
    

提交回复
热议问题