[ACCEPTED]-Why does xcopy exit with code 9009 in Visual Studio post-build step?-xcopy

Accepted answer
Score: 34

I encounted this error on the TeamCity build 3 server. I finally resolved it after checking 2 the build log and found:

"'xcopy' is not recognized as an internal or external command."

I then changed 1 my statement to:

C:\Windows\System32\xcopy "$(ProjectDir)config\Web.config.$(ConfigurationName)" "$(ProjectDir)Web.config" /Y/R

Score: 32

Restart Visual Studio. Worked for me


Score: 21

Found my answer: The command had a line 4 break between the source and destination 3 strings. So, Visual Sudio was treating it 2 as two commands. Eliminating the line break 1 solved the problem.

Score: 11

This error can occur if your system PATH 15 environment variable has been set incorrectly. The 14 path should contain (at the very least)


on 13 modern versions of Windows (see https://superuser.com/questions/124239/what-is-the-default-path-environment-variable-setting-on-fresh-install-of-window). I have 12 just found my system PATH had been set to 11

C:\Program Files (x86)\Bad Vendor\Buggy Program;

by an msi installer that obviously has issues.

If 10 you don't know how to edit the PATH via 9 the System Properties dialog, check out 8 this link : http://support.microsoft.com/kb/310519 - it's basically the same in 7 Windows 7 & 8 as it is in XP.

Finally, it's 6 worth noting that a lot of programs don't 5 notice if you update the PATH while they 4 are running, so closing down and re-opeing 3 programs like Visual Studio or command prompt 2 windows will be required for the repaired 1 path to take effect.

Score: 4

Your xcopy command failed for some reason.

I would 5 guess that either the DLL file doesn't exist 4 (eg, the build failed) or the target path 3 doesn't exist.

Run the same command line 2 in a command prompt and see what error it 1 prints.

Score: 2

Thanks for your help.

I gave complete path 1 of xCopy and it worked for me.


%windir%\system32\xCopy "$(ProjectDir)app\ExtjsWS\build\*.*" "$(publishUrl)\app\ExtjsWS\build" /y /i/e</PostBuildEvent>

Score: 1

Even though its a old post, I found fix 7 which may help some one.

What not helped me

Restarting visual studio.
Restarting computer
tried few steps as above and few more blogs

I am using Visual 6 Studio 2013.

What helped me.

Check the Environmental Variables check the PATH, does 5 it has all or nothing or only a part.

since 4 I was having backup of System PATH, I just 3 copy-pasted the variables Under

System Variables -> Path.

At last, I 2 gave rebuild to the project voila! it worked 1 for me.

Score: 1

In my case: i fix it do this: Add value 3 %SystemRoot%\system32 to Environmental variable's 2 Path variable,and restart my computer,rebuild 1 the solution,it goes fine.

Score: 0

Mostly related to path C\Program files...\some.exe. It 1 should be "C\Program files...\some.exe"

Score: 0

windows defender was blocking access for 4 me, because I get so many of these silly 3 push notifications I was just ignoring it 2 during the build process. Click the notification 1 and allow access for xcopy. Problem solved

More Related questions