Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

There are different ways to do this.

If dirs are:


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\


share|improve this answer
Oh my goodness. I used slashes instead of backslashes. Another reason to hate on Windows, possibly...? Thanks for your help, anyways. It's appreciated. – Franz Nov 5 '09 at 1:52
There's no need for the leading ".\" – John Gardeniers Nov 12 '09 at 1:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.