0

I am experiencing the following problem:

I would like to run ecd.exe from a command-line.

I have added its full path to the 'path' environment-variable.

When calling ecd.exe from command-line, I get the following output:

Error: ecd.exe should be located under the Eclipse home directory.

This executable runs correctly when I add its full path in the command-line.


I've figured that an identical file exists in some other path folder.

But I have not been able to find it anywhere within the file-system.

How can I find the path used by the command line when calling this executable?

barak manos
  • 29,648
  • 10
  • 62
  • 114
  • @a_horse_with_no_name: Thanks for the edit (wasn't really sure how to refer to "CMD"). Any chance you know how to resolve this? – barak manos Apr 14 '16 at 13:14
  • @a_horse_with_no_name: Under `C:\Freescale\CW MCU v10.6\eclipse`. – barak manos Apr 14 '16 at 13:58
  • @a_horse_with_no_name: I thought that the shell was executing a file of identical name from a different path. I wanted to know which path that might be. – barak manos Apr 14 '16 at 14:03

1 Answers1

2
@ECHO OFF
SETLOCAL
SET "pathd=%cd%;%path%"
SET "pathd=%pathd:)=^)%"
FOR /f "delims=" %%a IN ('echo %pathd:;=^&ECHO %') DO IF EXIST "%%~a\j*.exe" ECHO %%~a

GOTO :EOF

This should find - well, J*.exe files on the path (since I don't have ecd.exe) - just substitute ecd.exe for j*.exe.

It appends the current path to the current directoryname separated by ; then changes each ) to ^) in the resulting string.

The for operates on the concatenated enhanced path-string by substituting for ; with &echo - the carets before the ) on the previous line and the & in this line "escapes" the character, cause cmd to disregard the special meaning and treat it as an ordinary character.

This provides %%a as each individual path directory in turn; see whether the file (j*.exe) exists in the directory, and echo the directoryname if the file is found.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Yes - that would be an idea. – Magoo Apr 14 '16 at 13:58
  • Thanks, it's working!!! But unfortunately working, because it leads me to a dead end on my original purpose (which is to understand why it behaves in a different manner when I call it with / without the full path). Perhaps I should post a different question, I'll accept your answer in any case. Thanks again :) – barak manos Apr 14 '16 at 14:02