False 'Sharing Violation' Xcopy error message
After much trial and error I was able to determine why I was getting a shared violation
I was copying files from computer B to computer A
I thought the sharing violations were occurring because computer B was not allowing me to make a copy of those files [stored on its harddrive].
In actuality, the directory on computer A (computer copying to) had files which I could not write over. This is why I was getting the shared violation.
One of the files in the directory on computer A was an executable task which I thought had been killed (taskkill). However, this executable got overlooked in the taskkill (actually wasn’t listed in the task manager for some reason) process and this program was still running (the file was in use). Therefore, when I tried to overwrite the file, xcopy was denied access to overwrite this file/executable, resulting in shared violations.
I was under the impression that sharing violations would only occur during xcopy if the files on computer B would not allow the copy to occur.
Most of the times when you have this problem is because another executable program (exe) is somehow using the files you want to copy over. Just kill the program using task manager and the copy will work.
The /C
switch solved the issue for me. Xcopy then skipped the files that were opened by other programms and went on.