Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows batch file: calling executable in another directory

This seems like something simple, but I don't seem to be able to get it. I have a directory called "test" with an executable hello.exe that basically prints "hello" onto the screen.

I want to execute this program from the current directory using relative paths. So I write

test\hello.exe

Thinking it would execute the program "hello.exe" located in directory "test". But it doesn't. Am I missing something?

like image 793
MxLDevs Avatar asked Apr 17 '11 03:04

MxLDevs


1 Answers

Try the following in the batch file:

%~dp0test\hello.exe

The "%~dp0" is a variable that gets replaced with the full path of the batch file, so that it should work even if you don't set the current directory of the batch file.

like image 68
Polemarch Avatar answered Sep 28 '22 10:09

Polemarch