Problem Executing Batch File in Pre-Build Event

前端 未结 8 1387
攒了一身酷
攒了一身酷 2021-02-20 01:05

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:

相关标签:
8条回答
  • 2021-02-20 01:31

    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
    
    0 讨论(0)
  • 2021-02-20 01:37

    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!

    0 讨论(0)
提交回复
热议问题