1

I am trying to copy a file to a folder using the following batch script

echo xcopy \\path1\file.txt \\path2\backup

However, I get the following error:

UNC paths are not supported. Defaulting to the windows directory.

Is there a simple solution for this?

René Vogt
  • 43,056
  • 14
  • 77
  • 99
BCLtd
  • 1,459
  • 2
  • 18
  • 45

1 Answers1

2

For Single file copying, simply use copy

copy /Y \\path1\file.txt \\path2\backup

Other ways to create a network share:

for /f "tokens=2" %i in ('net use * \\server1\folder\') do set src=%%i & goto :continue
:continue
for /f "tokens=2" %i in ('net use * \\server2\backup\') do set dest=%%i & goto :cp
:cp
copy %src%\file.txt %dest% /Y
net use /d %src%
net use /d %dest%

The above will only work if you have credentials setup already.. if not, you can do it as:

net use \\server1\IPC$ /user:username password
Gerhard
  • 22,678
  • 7
  • 27
  • 43