2012-07-04 58 views
1

如何添加ELSE部分到此代碼,以便如果它找不到javac.exe它會給出相應的找不到JDK消息?If/else命令語法批量編輯

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

    Option 4) 
+0

快速谷歌搜索帶來了以下鏈接:http://www.robvanderwoude.com /ntif.php – Amir

+0

你已經問過關於它的[一個問題](http://stackoverflow.com/questions/11324685/if-exist-and-else-in-batch),並且你有了答案。或者你不是? –

回答

3

您可以將某些括號添加到您,如果statment,並添加ELSE之後

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