desktop shortcut using a UNC path?

mciv1522

Honorable
Mar 12, 2013
1
0
10,510
How do you get a shortcut that is located on a UNC path to copy to a users' desktop? I have this already written but it fails to copy the shortcut.link to the user's desktop. copy "\\share\shortcut to file.lnk" "C:\Users\%USERPROFILE%\Desktop\" /Y
 
Command prompt does not accept UNC paths. A simple way to get around this is to make the network location into a mapped drive and put, for example - copy "Z:\share\shortcut to file.lnk" "C:\Users\%USERPROFILE%\Desktop\" /Y

Another way would be to use the PUSHD command. It temporarily maps the drive and changes your current directory to it. So you could do this...

pushd \\share
copy "shortcut to file.lnk" "C:\Users\%USERPROFILE%\Desktop\" /Y
popd

EDIT:
Just as I edit the answer in I realise I was too slow and beaten to it by chugot9218! Good job :) I'm also bookmarking that DOS reference.
 
We have had to do this at work, you simply pushd "\\Network\Share\Here" at the top, which will map that as a drive using the last unassigned drive letter (usually z or something). Do what you need to with that share after, and then before the end of your file add popd, which will un-assign that temporary drive. I use this site for my dos reference: http://ss64.com/nt/ you can look into pushd and popd there if you need examples.