I\'m trying to execute a batch file during a pre-build event. I have a new project and have added foo.bat to it. The file contains the following line:
It's possible that you have another foo.bat
somewhere in the PATH
. Try to specify full path to your batch file like C:\Path\to\foo.bat
.
When project is being built the current directory is the one with the .vcproj
file. The command path should be specified relative to this directory, if it's not in the PATH
.
One more thing to try to diagnose the problem would be to specify cmd
in the pre-build event command explicitly like this:
cmd /c C:\Path\to\foo.bat
or even
C:\windows\system32\cmd.exe /c C:\Path\to\foo.bat
It looks like my problem was the length of the path to the batch file. As this was a proof of concept I let VS create it in the default location:
C:\Documents and Settings\UserXXX\My Documents\Visual Studio 2010\Projects\SolutionXXX\ProjectXXX\foo.bat
As soon as I moved the solution to a location with a shorter path it worked fine. =P
Thanks for the suggestions!