I have a batch script which needs to work with Windows XP (for the time being) and Windows 7. The script also copies a link to the Windows Desktop.

copy /Y path\to\the\link.lnk %ALLUSERSPROFILE%\Desktop\link.lnk

This works on Windows XP but not on Windows 7. There %ALLUSERSPROFILE%\Desktop is a junction and even with the admin account I get "Access denied" when executing the command. I thought junctions were there to forward me to the correct location (%PUBLIC%\Desktop in this case), but it seems it does not work.

Any way I can make a XP/7 compatible command line?

1 Answer 1


I use this on both Windows XP and Windows 7 to set a variable for which path to use. In this code AUDESKTOP is set depending on which OS it is being run on.


Then call the variable in the command line like this;

copy /Y "path\to\the\link.lnk" "%AUDESKTOP%\link.lnk"

As far as why it errors in Windows 7, make sure there are quotes around paths. If it still doesn't work, try to run as administrator.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.