Switch statement equivalent in Windows batch file

前端 未结 9 1070
無奈伤痛
無奈伤痛 2020-12-03 00:40

I wonder if there is a simple way to branch execution in a Windows batch file depending on the value of one single expression. Something akin to switch/case blocks in C, C++

9条回答
  •  失恋的感觉
    2020-12-03 01:29

    This is simpler to read:

    IF "%ID%"=="0" REM do something
    IF "%ID%"=="1" REM do something else
    IF "%ID%"=="2" REM do another thing
    IF %ID% GTR 2  REM default case...
    

提交回复
热议问题