What does "exited with code 9009" mean during this build?

Did you try to give the full path of the command that is running in the pre- or post-build event command?

I was getting the 9009 error due to a xcopy post-build event command in Visual Studio 2008.

The command "xcopy.exe /Y C:\projectpath\project.config C:\compilepath\" exited with code 9009.

But in my case it was also intermittent. That is, the error message persists until a restart of the computer, and disappears after a restart of the computer. It is back after some remotely related issue I am yet to discover.

However, in my case providing the command with its full path solved the issue:

c:\windows\system32\xcopy.exe /Y C:\projectpath\project.config C:\compilepath\ 

Instead of just:

xcopy.exe /Y C:\projectpath\project.config C:\compilepath\

If I do not have the full path, it runs for a while after a restart, and then stops.

Also as mentioned on the comments to this post, if there are spaces in full path, then one needs quotation marks around the command. E.g.

"C:\The folder with spaces\ABCDEF\xcopy.exe" /Y C:\projectpath\project.config C:\compilepath\

Note that this example with regards to spaces is not tested.


Error Code 9009 means error file not found. All the underlying reasons posted in the answers here are good inspiration to figure out why, but the error itself simply means a bad path.


It happens when you are missing some environment settings for using Microsoft Visual Studio x86 tools.
Therefore, try adding as a first command in your post-build steps:

For Visual Studio 2010 use:

call "$(DevEnvDir)..\Tools\vsvars32.bat"

As @FlorianKoch mentioned in comments, for VS 2017 use:

call "$(DevEnvDir)..\Tools\VsDevCmd.bat"

It should be placed before any other command.
It will set environment for using Microsoft Visual Studio x86 tools.


Most probably you have space in your resultant path.

You can work around this by quoting the paths, thus allowing spaces. For example:

xcopy "$(SolutionDir)\Folder Name\File To Copy.ext" "$(TargetDir)" /R /Y /I

Had the same variable after changing PATH variable from Environmental Variables in Win 7. Changing back to default helped.