Calling a batch file using relative path

batchbatch-filepath

Oh gosh, gotta expose myself as a noob here 😉

In Windows, I need to execute a batch file in a subdirectory of the working directory. However, just running subdir/foo.bat cmd1 cmd2 does not work, and I get an error saying

The command "subdir" cannot be found.

What am I doing wrong?

Best Answer

There are different ways to do this.

If dirs are:

c:\workdir\batfile-dir\

and you are currently in \workdir\

You can do this: .\batfile-dir\foo.bat

The thing to remember is that foo.bat will be running with a "current directory" of \workdir\

HTH