Unable to launch elasticsearch from bat file in windows 10


  • Running elasticsearch with echo on.

D:\Elastic\elasticsearch-8.2.3\bin>setlocal enabledelayedexpansion

D:\Elastic\elasticsearch-8.2.3\bin>setlocal enableextensions

D:\Elastic\elasticsearch-8.2.3\bin>SET params=''

D:\Elastic\elasticsearch-8.2.3\bin>SET checkpassword=Y

D:\Elastic\elasticsearch-8.2.3\bin>SET enrolltocluster=N

D:\Elastic\elasticsearch-8.2.3\bin>SET attemptautoconfig=Y

D:\Elastic\elasticsearch-8.2.3\bin>FOR /F "usebackq tokens=1* delims= " %A IN (!params!) DO (
SET previous=!current!
 SET current=%A
 SET params='%B'
 SET silent=N
 IF "!current!" == "-s" (SET silent=Y )
 IF "!current!" == "--silent" (SET silent=Y )
 IF "!current!" == "-h" (
SET checkpassword=N
 SET attemptautoconfig=N
 IF "!current!" == "--help" (
SET checkpassword=N
 SET attemptautoconfig=N
 IF "!current!" == "-V" (
SET checkpassword=N
 SET attemptautoconfig=N
 IF "!current!" == "--version" (
SET checkpassword=N
 SET attemptautoconfig=N
 IF "!current!" == "--enrollment-token" (
IF "!enrolltocluster!" == "Y" (
ECHO "Multiple --enrollment-token parameters are not allowed"  1>&2
 goto exitwithone
 SET enrolltocluster=Y
 SET attemptautoconfig=N
 IF "!previous!" == "--enrollment-token" (SET enrollmenttoken="!current!" )
 IF "!silent!" == "Y" (SET nopauseonerror=Y )  ELSE (
 IF "!previous!" == "--enrollment-token" SET SHOULD_SKIP=true
 IF "!current!" == "--enrollment-token" SET SHOULD_SKIP=true
 IF "!SHOULD_SKIP!" == "false" (IF "x!newparams!" NEQ "x" (SET newparams=!newparams! !current! )  ELSE (SET newparams=!current! ) )
 IF "x!params!" NEQ "x" (GOTO loop )

D:\Elastic\elasticsearch-8.2.3\bin>CALL "D:\Elastic\elasticsearch-8.2.3\bin\elasticsearch-env.bat"   || exit /b 1

D:\Elastic\elasticsearch-8.2.3\bin>set SCRIPT="D:\Elastic\elasticsearch-8.2.3\bin\elasticsearch-env.bat"

D:\Elastic\elasticsearch-8.2.3\bin>rem determine Elasticsearch home; to do this, we strip from the path until we

D:\Elastic\elasticsearch-8.2.3\bin>rem find bin, and then strip bin (there is an assumption here that there is no

D:\Elastic\elasticsearch-8.2.3\bin>rem nested directory under bin also named bin)

D:\Elastic\elasticsearch-8.2.3\bin>for %I in ("D:\Elastic\elasticsearch-8.2.3\bin\elasticsearch-env.bat") do set ES_HOME=%~dpI

D:\Elastic\elasticsearch-8.2.3\bin>set ES_HOME=D:\Elastic\elasticsearch-8.2.3\bin\

D:\Elastic\elasticsearch-8.2.3\bin>for %I in (":\Elastic\elasticsearch-8.2.3\bin") do set DIRNAME=%~nxI

D:\Elastic\elasticsearch-8.2.3\bin>set DIRNAME=bin

D:\Elastic\elasticsearch-8.2.3\bin>if not "bin" == "bin" (
for %I in ("D:\Elastic\elasticsearch-8.2.3\bin\..") do set ES_HOME=%~dpfI
 goto es_home_loop

D:\Elastic\elasticsearch-8.2.3\bin>for %I in ("D:\Elastic\elasticsearch-8.2.3\bin\..") do set ES_HOME=%~dpfI

D:\Elastic\elasticsearch-8.2.3\bin>set ES_HOME=D:\Elastic\elasticsearch-8.2.3

D:\Elastic\elasticsearch-8.2.3\bin>rem now set the classpath

D:\Elastic\elasticsearch-8.2.3\bin>set ES_CLASSPATH=!ES_HOME!\lib\*

D:\Elastic\elasticsearch-8.2.3\bin>set LAUNCHERS_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!\lib\launchers\*

D:\Elastic\elasticsearch-8.2.3\bin>set HOSTNAME=DESKTOP-OB4JG19

D:\Elastic\elasticsearch-8.2.3\bin>if not defined ES_PATH_CONF (set ES_PATH_CONF=!ES_HOME!\config )

D:\Elastic\elasticsearch-8.2.3\bin>rem now make ES_PATH_CONF absolute

D:\Elastic\elasticsearch-8.2.3\bin>for %I in ("D:\Elastic\elasticsearch-8.2.3\config..") do set ES_PATH_CONF=%~dpfI

D:\Elastic\elasticsearch-8.2.3\bin>set ES_PATH_CONF=D:\Elastic\elasticsearch-8.2.3\config

D:\Elastic\elasticsearch-8.2.3\bin>set ES_DISTRIBUTION_FLAVOR=default

D:\Elastic\elasticsearch-8.2.3\bin>set ES_DISTRIBUTION_TYPE=zip

D:\Elastic\elasticsearch-8.2.3\bin>set ES_BUNDLED_JDK=true

D:\Elastic\elasticsearch-8.2.3\bin>if "true" == "false" (echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release"  1>&2 )

D:\Elastic\elasticsearch-8.2.3\bin>cd /d "D:\Elastic\elasticsearch-8.2.3"

D:\Elastic\elasticsearch-8.2.3>rem now set the path to java, pass "nojava" arg to skip setting ES_JAVA_HOME and JAVA

D:\Elastic\elasticsearch-8.2.3>if "" == "nojava" (exit /b )

D:\Elastic\elasticsearch-8.2.3>rem comparing to empty string makes this equivalent to bash -v check on env var

D:\Elastic\elasticsearch-8.2.3>rem and allows to effectively force use of the bundled jdk when launching ES

D:\Elastic\elasticsearch-8.2.3>rem by setting ES_JAVA_HOME=

D:\Elastic\elasticsearch-8.2.3>if defined ES_JAVA_HOME (
set JAVA="\bin\java.exe"
)  else (
rem use the bundled JDK (default)
 set JAVA="D:\Elastic\elasticsearch-8.2.3\jdk\bin\java.exe"
 set "ES_JAVA_HOME=D:\Elastic\elasticsearch-8.2.3\jdk"
 set JAVA_TYPE=bundled JDK

D:\Elastic\elasticsearch-8.2.3>if not exist !JAVA! (
echo "could not find java in !JAVA_TYPE! at !JAVA!"  1>&2
 exit /b 1

D:\Elastic\elasticsearch-8.2.3>rem do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)

D:\Elastic\elasticsearch-8.2.3>if defined JAVA_TOOL_OPTIONS (
echo warning: ignoring JAVA_TOOL_OPTIONS=

D:\Elastic\elasticsearch-8.2.3>rem warn that we are not observing the value of $JAVA_HOME

D:\Elastic\elasticsearch-8.2.3>if defined JAVA_HOME (echo warning: ignoring JAVA_HOME=E:\Program Files\Java\jdk-; using bundled JDK  1>&2 )
warning: ignoring JAVA_HOME=E:\Program Files\Java\jdk-; using bundled JDK

D:\Elastic\elasticsearch-8.2.3>rem JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we

D:\Elastic\elasticsearch-8.2.3>rem warn them that we are not observing the value of

D:\Elastic\elasticsearch-8.2.3>if defined JAVA_OPTS (
(echo | set /p=warning: ignoring JAVA_OPTS=;  )
 echo pass JVM parameters via ES_JAVA_OPTS

D:\Elastic\elasticsearch-8.2.3>rem check the Java version

D:\Elastic\elasticsearch-8.2.3>"D:\Elastic\elasticsearch-8.2.3\jdk\bin\java.exe" -cp "D:\Elastic\elasticsearch-8.2.3\lib\*;D:\Elastic\elasticsearch-8.2.3\lib\launchers\*" "org.elasticsearch.tools.java_version_checker.JavaVersionChecker"   || exit /b 1

D:\Elastic\elasticsearch-8.2.3>IF ERRORLEVEL 1 (
IF NOT DEFINED nopauseonerror (PAUSE)
 EXIT /B 0

D:\Elastic\elasticsearch-8.2.3>SET KEYSTORE_PASSWORD=

D:\Elastic\elasticsearch-8.2.3>IF "Y" == "Y" (
CALL "D:\Elastic\elasticsearch-8.2.3\bin\elasticsearch-keystore.bat" has-passwd --silent
SET /P KEYSTORE_PASSWORD=Elasticsearch keystore password:
ECHO Failed to read keystore password on standard input
warning: ignoring JAVA_HOME=E:\Program Files\Java\jdk-; using ES_JAVA_HOME
Le chemin d’accès spécifié est introuvable.


Hello @Halim_Dris

This warning means that you have to set the java 's environmental variable to ES_JAVA_HOME

In command prompt just check whether this variable already set or not using this command echo %ES_JAVA_HOME%

Could you please set the same in environmental variable under SYSTEM VARIABLE if its not set

  • Thank you sudhagar_ramesh, but the problem come from
    the line 105 of file elasticsearch.bat

echo %ES_JAVA_HOME% = D:\Elastic\elasticsearch-8.2.3\jdk

      -Des.path.home="%ES_HOME%" ^
      -Des.path.conf="%ES_PATH_CONF%" ^
      -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
      -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" ^
      -cp "!ES_CLASSPATH!;!ES_HOME!/lib/tools/security-cli/*;!ES_HOME!/modules/x-pack-core/*;!ES_HOME!/modules/x-pack-security/*" "org.elasticsearch.xpack.security.cli.AutoConfigureNode" !newparams!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.