I have a .bat and .exe file in the same folder. I could not call the .exe from .bat unless I put the full absolute path to it. Is there a way to not specify a path?
.bat
.exe
Try calling .exe with %~dp0 , for example: %~dp0MyProgram.exe .
%~dp0
%~dp0MyProgram.exe
%0 contains the full path to the .bat file to be called.
%0
~dp says to get the drive and path, including trailing \ .
~dp
\
I solved this by changing the working directory using pushd at the beginning of the script, and recovery is at the end of the script using popd . Thus, you can always assume that the working directory matches the location of the bat file.
pushd %~dp0 ProgramInSameFolderAsBat.exe popd
seems strange? I have never worked on windows, but
Have you tried with. /
./program.exe
really shouldn't be a difference? is it possible that the bat is executed from the context of C: \ Windows, or at some point does your batch make any disk in another directory?