I get a random error using xcopy, I have an exit code 4.

Lorenzo Zambelli 180 Reputation points
2025-03-24T14:16:02.05+00:00

I'm running msbuild.exe in a hyper-v virtual machine using Windows 11 24H2 Home Edition.

The physical computer has a thread ripper pro process with 64 logic cores.

I have a total random error from xcopy with exit code 4 so my dll file won't be copied in the destination folder.

Destination paths are correct, and source files are ok too.

I already tried killing the previous msbuild processes, increase RAM of VM (enabling dynamic memory on VM), tried decreasing parallel builds.

We tried using robocopy instead of xcopy, but because of its return codes are different from what expected we are still getting errors.

Windows for business Windows Client for IT Pros User experience Other
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-03-26T01:29:49.0066667+00:00

    Hello,

    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."

    So I suggest you to check your drive name or run it manually for testing .


    If the Answer is helpful, please click "Accept Answer" and upvote it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.