Script CMD de Windows para obtener el directorio en el que existe el archivo

I have a executable file VSTO.exe & una try.bat file in one folder. I want to get the folder path of the bat file & concat that path with VSTO.exe.

I have this script in my try.bat.

"%~fp0\VSTO.exe" /q

but it creates path: "G:\test\try.bat\VSTO.exe" . I want to get a path "G:\test\VSTO.exe"

can anyone tell me how do i do that?

preguntado el 03 de mayo de 12 a las 11:05

2 Respuestas

contestado el 23 de mayo de 17 a las 12:05

Prueba con esto

SET CURDIR=%CD%
"%CURDIR%\VSTO.EXE" /q

The %CD% pseudo-variable expands to the current working directory.
Type SET /? to see other pseudo-variable (last page)

contestado el 03 de mayo de 12 a las 11:05

Do you have extensions enabled? (cmd /x to enable, cmd /y to disable) - Steve

yes. it is giving exception like 'not identified as internal or external command' - Sangram Nandkhile

But that file "VSTO.EXE" is in the current directory where you execute the try.bat? And the current directory contains spaces? (Answer updated to account for directory with spaces) - Steve

If the executable is in the current directory, why not just say .\vsto.exe? - Harry Johnston

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.