4

I have a executable file VSTO.exe & a 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?

2 Answers 2

7
"%~dp0\VSTO.exe" /q

is the exact answer.

How to get folder path from file path with CMD

Sign up to request clarification or add additional context in comments.

Comments

1

Try with this

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)

4 Comments

Do you have extensions enabled? (cmd /x to enable, cmd /y to disable)
yes. it is giving exception like 'not identified as internal or external command'
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)
If the executable is in the current directory, why not just say .\vsto.exe?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.