valid syntax for copy from unc to unc

  • Thread starter Thread starter LarryG
  • Start date Start date
L

LarryG

Can anyone tell me what is wrong with the following syntax.

copy \\server\share\dir\file.dat %userprofile%\desktop


is the output illegal?

TIA
 
LarryG said:
Can anyone tell me what is wrong with the following syntax.

copy \\server\share\dir\file.dat %userprofile%\desktop

is the output illegal?

By "output" I am assuming you mean the destination filename...

This probably won't work on a Windows 2000 or later system because when
cmd.exe expands the environment variable %USERPROFILE%, it contains one or
more spaces, and so the copy command will attempt to copy the input file to
(most likely) c:\documents, rather than the entire directory.

Solution: Enclose the destination filename in quotes.

Keep in mind that environment variables are expanded by cmd.exe on the
local computer, and the contents may not match on a remote system.

HTH,

Bill
 
%userprofile% probably expands to a path containing spaces, try


copy "\\server\share\dir\file.dat" "%userprofile%\desktop"

BTW, "%userprofile%\desktop" isn't a UNC
 
Back
Top