xcopy problem – Invalid drive specification – 0 File(s) copied

Recently I started getting the following errors from one of my batch files.

Invalid drive specification
0 File(s) copied

The problem was, that I didn’t have specified drive at all, because I was using UNC path (\\ComputerName\SharedFolder\Resource).

So, xcopy is reporting with the wrong error message.

One possibility is, that it is possible to disable UNC paths in xcopy altogether – see the Microsoft KB Q192808.

In my situation, error was caused by broken network connection. Issuing:
net use \\ComputerName\SharedFolder\Resource /USER:user_name password
right before xcopy, fixed the problem.