开发者

Check if JAVA_HOME is present in environment using batch script

开发者 https://www.devze.com 2023-03-27 13:19 出处:网络
I want to check whether JAVA_HOME is present in environment or not So I wrote the below script a.bat if \"%JAVA_HOME%\" == \"\"

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

精彩评论

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