如果批处理编辑中的/ else命令语法

时间:2012-07-04 08:18:31

标签: batch-file

如何在此代码中添加ELSE部分,以便在找不到javac.exe时,它会提供相应的找不到JDK 消息?

 FOR /R "C:\Program Files" %%a IN (.) DO (
        IF EXIST "%%~a\javac.exe" ECHO You Have The Java Dev Kit Ignore 

    Option 4) 

2 个答案:

答案 0 :(得分:3)

您可以在IF语句中添加一些括号,然后添加ELSE

IF EXIST "%%~a\javac.exe" (
        ECHO You Have The Java Dev Kit Ignore 
    ) ELSE (
        ECHO Cannot Find JDK
    )

答案 1 :(得分:1)

  IF EXIST "%%~a\javac.exe" (ECHO You Have The Java Dev Kit Ignore) ELSE ( do something else )