Click here to Skip to main content
15,891,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

I am trying to solve this problem almost two days. I am working on legacy .bat file which is running by windows scheduler at windows server 2008. But XCOPY copies 3 files which are very light but most of the time it doesn't copy the largest file. Last week it successfully copied all files in 6 days. This week it didn't copy the largest file three days. That means it failed to copy the largest (1 GB) 3 out of 4 days.

What is the problem in the XCOPY which is given below:

XCOPY : xcopy %bckp%\*.*/v/e/s/c/y/z %drv%\bckp_%day% 2>>&1 | %tee% %run% 1>>%log% 2>&1

Please help me!

-----
Shafik

What I have tried:

XCOPY is not working all the time. But I need it to make stable. Please help me.
Posted
Updated 6-Sep-16 13:14pm
Comments
David_Wimbley 6-Sep-16 18:49pm    
If its copying some buy not all it would seem to me that this is probably a network issue than an xcopy issue. Do you know if you are having connectivity issues in the time where your certain files don't send like they ought too?
Shafikul 6-Sep-16 19:07pm    
Thank You so much David, You are so kind brother. I found there is no network issue. In the log file it copied 3 files when it was trying to copy the largest one it shows : Access denied. That is only error message i am getting all the time.

1 solution

There is nothing in the command line that will cause this.

The problem has a number of causes. First first being a network connection between the machine running this batch file and the source and destination file locations.

Next, the files could be locked and in use when XCOPY gets to the file.

Look in the log files you're generating to see what the errors are.

Lastly, don't use XOPY. Use something like ROBOCOPY since XCOPY will not restart the copy operation is there is a failure. ROBOCOPY will try again if there is a problem.
 
Share this answer
 
Comments
Shafikul 6-Sep-16 19:21pm    
Thanks again, I have seen that lot of experts adviced to use robocopy but it is legacy I don't want to use it. And yes some how file becomes locked. I got the error message in my log is : "Access denied"
after coping three files. Please tell me what should I add in the code so that
file will not be locked.
Dave Kreskowiak 6-Sep-16 19:51pm    
Robocopy is Legacy? WHO THE HELL CARES!?!? XCOPY is even MORE legacy!

Robocopy is FAR MORE ROBUST than XCOPY. THAT'S WHY you use it.
Dave Kreskowiak 6-Sep-16 19:52pm    
There is no code you can add to "unlock" or prevent another app from locking the file.

If an app needs the file, it's going to open it itself and there's nothing you can do to prevent that. You're only option is to retry the copy after a delay and try again. This is something that XCOPY will NEVER do but Robocopy will!
Shafikul 6-Sep-16 19:26pm    
I have used /z which will restart : Copies over a network in restartable mode.
Dave Kreskowiak 6-Sep-16 19:49pm    
But XCOPY will only try once.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900