batch file, robocopy problem: ERROR 1921 (0x00000781)

I use the following batch file to back up files in the C:\users\Administrator account. The batch file is run as "back-to-1 g"

if exist %1:\users robocopy C:\users\Administrator %1:\users /s /xo /xf ~*.* *.dat *.LOG* /log+:c:\back-to-%1.txt

For some reason, robocopy would create directory under \Application Data recursively, something like the following:

New Dir          0 C:\users\Administrator\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\Adobe\TypeSupport\
 New Dir          2 C:\users\Administrator\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\Adobe\TypeSupport\CS5\

Eventually, I got something like the following which I cannot delete because the path name is too long:

2013/10/13 21:02:24 ERROR 1921 (0x00000781) Scanning Source Directory C:\users\Administrator\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\Application Data\
The name of the file cannot be resolved by the system.

Has anyone seen this problem before?
|
Answer
Answer

Hi

 

The Recursion you are seeing is caused by the Application Data folder, which is actually a Junction.

 

This can happen when your Robocopy batch file encounters a Junction or Symbolic Link in the Users folder.

 

You can easily fix this problem by including the /xj switch in the command.

 

Here is the documentation:

 


/xj  Excludes junction points, which are normally included by default.

 


Robocopy:

http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx
 

 

Regards

MVP 1999 - Present
Windows Insider MVP

30 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 8, 2022 Views 11,693 Applies to: