How to use if - else structure in a batch file?

前端 未结 8 752
南方客
南方客 2020-11-28 03:53

I have a question about if - else structure in a batch file. Each command runs individually, but I couldn\'t use \"if - else\" blocks safely so these parts of my programme d

8条回答
  •  余生分开走
    2020-11-28 04:02

    here is how I handled if else if situation

    if %env%==dev ( 
        echo "dev env selected selected"
    ) else (
        if %env%==prod (
            echo "prod env selected"
        )
    )
    

    Note it is not the same as if-elseif block as the other programming languages like C++ or Java but it will do what you need to do

提交回复
热议问题