batch file - System cannot find path/command not found error in Powershell -


i have installation of elasticsearch has worked fine months has inexplicably gone missing according powershell. thing can think of has changed updated java.

when try run using full path following error:

ps c:\> c:\elasticsearch\bin\elasticsearch.bat system cannot find path specified. 

the path exists , there no spelling error can see here:

ps c:\elasticsearch\bin> dir      directory: c:\elasticsearch\bin  mode                lastwritetime         length name ----                -------------         ------ ---- -a----         8/7/2016  10:13 pm           5551 elasticsearch -a----         8/7/2016  10:13 pm         104448 elasticsearch-service-mgr.exe -a----         8/7/2016  10:13 pm         103936 elasticsearch-service-x64.exe -a----         8/7/2016  10:13 pm          80896 elasticsearch-service-x86.exe -a----         8/7/2016  10:13 pm            909 elasticsearch.bat -a----         8/7/2016  10:13 pm           3307 elasticsearch.in.bat -a----         8/7/2016  10:13 pm           2814 elasticsearch.in.sh -a----         8/7/2016  10:13 pm           2992 plugin -a----         8/7/2016  10:13 pm           1303 plugin.bat -a----         8/7/2016  10:13 pm           6501 service.bat 

when try run within directory itself, following message:

ps c:\elasticsearch\bin> elasticsearch.bat elasticsearch.bat : term 'elasticsearch.bat' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again. @ line:1 char:1 + elasticsearch.bat + ~~~~~~~~~~~~~~~~~     + categoryinfo          : objectnotfound: (elasticsearch.bat:string) [], commandnotfoundexception     + fullyqualifiederrorid : commandnotfoundexception  suggestion [3,general]: command elasticsearch.bat not found, exist in current location. windows pow ershell not load commands current location default. if trust command, instead type: ".\elastic search.bat". see "get-help about_command_precedence" more details. 

i don't have strong knowledge of handling powershell errors, have tried few things:

  1. reinstalling elasticsearch
  2. adding directory containing elasticsearch.bat path
  3. running elasticsearch.bat using command ./elasticsearch.bat

none of these change anything.

here's content of elasticsearch.bat:

@echo off  setlocal enabledelayedexpansion title elasticsearch 2.3.5  set params='%*'  :loop /f "usebackq tokens=1* delims= " %%a in (!params!) (     set current=%%a     set params='%%b'     set silent=n      if "!current!" == "-s" (         set silent=y     )     if "!current!" == "--silent" (         set silent=y     )         if "!silent!" == "y" (         set nopauseonerror=y     ) else (         if "x!newparams!" neq "x" (             set newparams=!newparams! !current!         ) else (             set newparams=!current!         )     )      if "x!params!" neq "x" (         goto loop     ) )  set hostname=%computername%  call "%~dp0elasticsearch.in.bat" if errorlevel 1 (     if not defined nopauseonerror (         pause     )     exit /b %errorlevel% )  "%java_home%\bin\java" %java_opts% %es_java_opts% %es_params% -cp "%es_classpath%" "org.elasticsearch.bootstrap.elasticsearch" start !newparams!  endlocal 

ps c:\> c:\elasticsearch\bin\elasticsearch.bat system cannot find path specified. 

are sure that's not the output of batch file? in other words, in batch file cannot find path specified (perhaps java.exe). if powershell can't find file, you'll error message second attempt.

speaking of second attempt:

ps c:\elasticsearch\bin> elasticsearch.bat 

as error message states, won't work files in current folder. need explicitly specify current folder:

ps c:\elasticsearch\bin> .\elasticsearch.bat 

Comments