What's causing xcopy to tell me Access Denied?

OwenP picture OwenP · Mar 18, 2009 · Viewed 84.6k times · Source

The postbuild task for one of our solutions uses xcopy to move files into a common directory for build artifacts. For some reason, on my computer (and on a VM I tested), the xcopy fails with "Access Denied". Here's what I've done to try and isolate the problems:

  • I tried a normal copy; this works.
  • I double-checked that none of the files in question were read-only.
  • I checked the permissions on both the source and destination folder; I have full control of both.
  • I tried calling the xcopy from the command line in case the VS build process had locked the file.
  • I used Unlocker and Process Explorer to determine there were no locks on the source file.

What have I missed, other than paranoid conspiracy theories involving computers out to get me? This happens on my dev machine and a clean VM, but doesn't happen for anyone else on the project.

Answer

Tamir picture Tamir · Jul 23, 2014

/r = Use this option to overwrite read-only files in destination. If you don't use this option when you want to overwrite a read-only file in destination, you'll be prompted with an "Access denied" message and the xcopy command will stop running.

That's was mine resolution to this error.

Source