Can I have an IF block in DOS batch file?

前端 未结 5 2148
梦谈多话
梦谈多话 2020-12-05 03:41

In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use () for an if block just like the {} used

5条回答
  •  醉酒成梦
    2020-12-05 04:06

    Maybe a bit late, but hope it hellps:

    @echo off 
    
    if %ERRORLEVEL% == 0 (
    msg * 1st line WORKS FINE rem You can relpace msg * with any othe operation...
    goto Continue1
    )
    :Continue1
    If exist "C:\Python31" (
    msg * 2nd line WORKS FINE rem You can relpace msg * with any othe operation...
        goto Continue2
    )
    :Continue2
    If exist "C:\Python31\Lib\site-packages\PyQt4" (  
    msg * 3th line WORKS FINE rem You can relpace msg * with any othe operation...
        goto Continue3
    )
    :Continue3
    msg * 4th line WORKS FINE rem You can relpace msg * with any othe operation...
        goto Continue4
    )
    :Continue4
    msg * "Tutto a posto" rem You can relpace msg * with any othe operation...
    pause
    

提交回复
热议问题