1

我将如何在其中添加和 Else 选项来表示:
您没有 java 开发工具包,请选择选项 4?

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

2 回答 2

1

您需要搜索所有子目录以确定它是否存在。

set found=0
FOR /R "C:\Program Files" %%a IN (.) DO (
    IF EXIST "%%~a\javac.exe" set found=1
)
if %found%==0 (
   ECHO You don't have the java dev kit please select option 4
) ELSE (
   echo Found javac.exe
)
于 2012-07-04T08:18:33.010 回答
0
SET found=0
FOR /R "C:\Program Files" %%a IN (.) DO (
    IF EXIST "%%~a\javac.exe" ( ECHO You Have The Java Dev Kit Ignore Option 4 
    SET found=1)
) 
IF %found%==0 ( ECHO You don't have the java dev kit please select option 4 )

如果你想要 ELSE,你必须使用()括号。

于 2012-07-04T08:18:28.997 回答