xcopy suddenly stopped working

I have a batch file with several xcopy commands that I have been using for years. All of a sudden the xcopy commands have stopped working giving me an Access Denied message for every file that xcopy tries to copy to the local computer. An example of an xcopy command:

C:\Windows\System32\xcopy.exe "\\Motion\Users\Nelson\Documents\My ElephantDrive\Everywhere\Patent Records" "C:\Users\User\Documents\My ElephantDrive\Everywhere\Patent Records" /D /S /Y /C  /EXCLUDE:C:\xcopyexclude.lst

I have turned off my virus protection (Bitdefender) and checked the permissions for the folders (there has been no change and I added full control for everyone just to be sure).  I can copy the files xcopy is trying to copy with Windows Explorer with no trouble.  The batch file is in my desktop. Any ideas what may be causing this behavior?
LVL 39
thenelsonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

William MillerIT SpecialistCommented:
Are you copying via GPO or running it manually per machine?
thenelsonAuthor Commented:
Manually running a batch file on one computer.
NVITEnd-user supportCommented:
Is it run via the Task Scheduler? Or does the user just double click to run it?

> I can copy the files xcopy is trying to copy with Windows Explorer with no trouble
To confirm, have you tried running the sample line you showed us in a CMD window as the same user?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

thenelsonAuthor Commented:
I just double click to run it.
Bill BachPresident and Btrieve GuruCommented:
There are two possibilities -- access to the source file is denied, or access to the target location is denied. Unfortunately, XCOPY doesn't tell you which.  Try running Process Monitor from SysInternals (www.sysinternals.com) and let it capture activity when you start the copy process.  Stop it as soon as you get the error, then look for the attempts at accessing the files.  Hopefully, this will shed some more light on the problem and at least tell you which side is broken.

FYI -- I always like to PUSH files when possible, not PULL them.  The advantage to pushing the files (from the source computer) is that you can always enable the use of VSS Snapshots on the source box, mount the snapshot as a drive letter with DOSDEV, and then make a clean, crash-consistent copy of the data from the temporary drive letter.  When you're done, you simply release the snapshot.  The tool VSCSC makes this VERY easy to accomplish, as it can even call your batch file for you as soon as the snapshot is ready!
Life1430Commented:
Just try executing Xcopy from a command window in Run as Administrator mode and see if that works

  1. Right Click CMD
  2. Run as Administrator
  3. Navigate to your batch file
  4. Run the batch file.
thenelsonAuthor Commented:
Bill,
Here are the the first two lines from the Process Monitor referencing the xcopy call. I have not used Process Monitor before so I am unsure as to what I am seeing. It looks like xcopy cannot find the file o the other computer. I changed the patient's name in the first path to [patient name] for privacy concerns. I don't understand the path: "C:\Windows\CSC\v2.0.6\namespace\Motion". Any guidance you can give me would be appreciated.

8:46:02.6962655 PM      xcopy.exe      1920      CreateFile      \\Motion\Users\Nelson\Documents\My ElephantDrive\Everywhere\Patent Records\[patient name]      SUCCESS      Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened

8:46:02.6964881 PM      xcopy.exe      1920      CreateFile      C:\Windows\CSC\v2.0.6\namespace\Motion      NAME NOT FOUND      Desired Access: Read EA, Write EA, Read Attributes, Write Attributes, Delete, Read Control, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

The batch file is a sync routine. It firsts pull files from the other computer to my computer. Then it pushes files from my computer to the other computer.  As I stated in my question, it has been running perfectly for years until today.

Sarang,
I did run xcopy in a command window but not one elevated to Administrator mode. Good thought. Unfortunately I still got access denied.
thenelsonAuthor Commented:
An additional bit of information:  
I was able to successfully copy a file using the Windows copy command from  
\\Motion\Users\Nelson\Documents\My ElephantDrive\Everywhere\Patent Records
to
C:\Users\User\Documents\My ElephantDrive\Everywhere\Patent Records
that xcopy produced an Access Denied message.  I ran the copy command in the same command window in xcopy failed.
thenelsonAuthor Commented:
I found the answer:
https://stackoverflow.com/questions/659463/whats-causing-xcopy-to-tell-me-access-denied
/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.

A short time ago, I removed the /r option because xcopy was overwriting read-only files that I didn't want overwritten.  I didn't know that xcopy would report each read-only file with Access denied. I don't see an option in xcopy to not report these "errors".
Bill BachPresident and Btrieve GuruCommented:
Were those the ONLY two lines reported by XCOPY?  I would have expected a lot more than just two.

The first call successfully opens a file handle to the source file.  (While the call to CreateFile can create a file, it is also used to open an existing file and create a file handle to it, so this is correct.)

The second call is attempting to open a file handle within the Windows Client Side Cache (CSC) for the Motion folder.  This fails, as the foilder Motion is not found in the cache.

It is the second call that makes me wonder -- this is NOT from the directory in which you asked for the XCOPY, and this is NOT the same Access Denied error.  There HAS to be more calls further on down in the list.  

I understand the need for patient name privacy.  However, perhaps it makes sense to create a folder under PatientRecords called "TestPatient", fill it with a few test files, and then change the batch file to specify the lower level folder.  With that, you can capture the calls with ProcMon, add a filter so you see ONLY those from XCOPY, and then save and post the filtered trace file.

Another option would be to consider RoboCopy instead.  This tool is much faster than XCOPY, and it can also be used to "mirror" a folder, which copies newer data AND deletes data files that are no longer present on the source folder from the target.  This tool has a lot more switches, too, but with your XCOPY switches, I am guessing that /MIR along with some /XF options to exclude files.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thenelsonAuthor Commented:
Bill,
I just copied the two lines thinking that would be enough. I have been thinking of switching to robocopy. Since I discovered the Access denied message is due to removing the /r flag, I am going to close  the question. Thanks for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.