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%
精彩评论