Search code examples
windowsvisual-studio-2008post-build-eventpost-build

PostBuild in Visual Studio 2008 not working under Windows 7 or Windows 8.1


I defined a post-build-event in Visual Studio 2008:

%ProgramFiles%\TortoiseHG\xy.exe

When compiling under Windows 7 or Windows 8.1 (x64) I got the following error-message:

Error   1   The command "%ProgramFiles%\TortoiseHG\xy.exe" exited with code 9009.   MyProjektName

The program is here:

C:\Program Files\TortoiseHg

In Windows XP (x86) it is working perfectly - also did I try to set quotation marks but it didn't help. Any ideas what could be wrong? Is it a problem due to the fact that there are two program-paths (one for x86 and one for x64)? But even when I copy the xy.exe to C:\Program Files (x86)\TortoiseHg\, I do get the same error.

Help is appreciated! Thank you.


Solution

  • under Windows 7 or Windows 8.1 (x64)

    That's certainly one of the basic problems, Visual Studio is a 32-bit process. The file redirector will act up and redirect any access from c:\program files to c:\program files (x86). To die there, you don't have TortoiseHG installed there.

    But not your only problem, the redirection will produce error code 3, not 9009. So you did not get this far yet, 9009 is a general failure code produced when the program you start exits with an error code. Missing double quotes is enough to trigger it, also the program itself failing for whatever reason. Pretty important to look in the Output window for any error message.

    Short from an error message we don't know about, you'd get closer with:

       %windir%\sysnative\cmd.exe /c "%programw6432%\TortoiseHG\xy.exe"
    

    Which starts the 64-bit command processor, thus ensuring that the file system redirector stays out of the way. The /c option asks it to execute the command that follows and then exit. The %programw6432% environment variable ensures you'll pass c:\program files and not the 32-bit path. Double-quotes around it to ensure that the spaces in the path don't cause misery.