The concept of "working directory" during program startup or "current directory" of the running process is an interesting topic in itself. Maybe I'll write another time about how to manipulate it in different programming languages. This time enough to say that some programs look for auxilliary files in working directory, some in the directory where own EXE file is located and some in other places like user's profile directory.
Problems begin when a program needs auxilliary files located in same directory as executable, but uses working directory to locate it. Apparently such program expects to always be ran with working directory equal to path of its EXE. It happened to me yesterday while using Windows port of Bison (parser generator). Error was:
win_bison: cannot open file `data/m4sugar/m4sugar.m4': No such file or directory
I can't just run the program with another working directory because I execute it from Visual C++, as a Custom Build Tool associated with my ".y" file. There is only place to enter a command in file property page, no place to change working directory, which is by default the directory of Visual C++ project I think.
The solution I found to be able to run a console command with given parameters and also with given working directory is to do it indirectly, using system "start" command, like this:
start /B /WAIT /D <WorkingDir> <ExePath> <Parameters>
Update 2012-11-29: I was informed that the problem in win_bison is now fixed so it can be used without such workaround.