开发者

Check if JAVA_HOME is present in environment using batch script

I want to check whether JAVA_HOME is present in environment or not So I wrote the below script a.bat

if "%JAVA_HOME%" == "" 
(
echo Enter path to JAVA_HOME: 
set /p javahome=
)
if not "%JAVA_HOME%" == ""
(
echo %JAVA_HOME%
)

It shows "The syntax of the command is incorrect" where am i going wron开发者_运维百科g?


Try this:

@echo off
IF "%JAVA_HOME%" == "" (
    echo Enter path to JAVA_HOME: 
    set /p JAVA_HOME=
) ELSE (
    echo %JAVA_HOME%
)


if not defined JAVA_HOME (
    :undefined
    set /p JAVA_HOME=Enter path to JAVA_HOME:
    if not defined JAVA_HOME goto:undefined
 )
echo %JAVA_HOME%
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜