4

I am running a build from Team Foundation Server(TFS), and the build is failing with the error

    "xcopy "C:\eComObjects_MP10\Microsoft\DynamicsCrm" 
    "D:\Builds\19\Unicorn\MaintPackage10- Daily\Sources\MaintPackage10\WebInterface\Store\Inetpub\wwwroot\Bin\DynamicsCrm" 
    /E /Y /I " exited with code 4".

When I simply go to the command prompt and run the above command, it fails, but when this command is run after removing /E/Y/I and the double quotes at the end, it works fine from the command prompt. What might be wrong here ?

TVicky
  • 353
  • 3
  • 13
  • 36

2 Answers2

3

Since it's also failed with command prompt, so it's not related to TFS build.

Xcopy exit code 4 means "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."

There are various reasons for this. In your case it may due to the length of Source and Destination (Path length). resulting path names exceeded the maximum allowed length. It may due to the /e option /e : Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options. Xcopy command reference.

For more ways, you could refer below similar question:

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • You rightly mentioned in your answer - "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.". I found that the syntax wasn't right on the command line. – TVicky May 21 '17 at 11:31
  • 1
    In one instance, I got this message because I had opened a file in the target directory with an application that locked the file. This caused xcopy to “exit with code 4”. That message itself wasn’t clear to me but the build Output was a little more helpful: “File creation error - The requested operation cannot be performed on a file with a user-mapped section open.” – BernieP Apr 18 '18 at 17:17
1

In addition to the possibility of disk space or command line syntax errors, this can also occur due to permissions (and maybe other causes?)

What I would recommend is to open a command prompt and copy/paste the offending XCOPY command so you can see the actual error that's occurring. In my case it was "Access Denied" which prompted me to check the destination folder where I found that my user account didn't have appropriate access.

Rick Riensche
  • 1,050
  • 1
  • 12
  • 25