0

I would like to check if a java file exists on the PC and if it does, get the path of the file (excluding the filename) and use it in a variable. I need to do this using a batch file.

I have gotten as far as the following command which displays the full path of the .exe file:

for %i in (java.exe) do @echo.   %~$PATH:i

The result being:

C:\Program Files\Common Files\Oracle\Java\javapath\java.exe

However, I'm unable to proceed further, as I need to extract the path, excluding the filename. Alternatively, there might be a command which just returns the path of the folder.

Can someone please help me out?

robinCTS
  • 4,407

0 Answers0