Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Vista/7, if I try to delete a shortcut using the following command -:

del "%allusersprofile%\Desktop\MyShortcut.lnk"

...Windows sees this folder as empty and doesn't delete the file.

The environment variable "allusersprofile" points to "C:\ProgramData" however "Desktop" is actually a soft symbolic link to the C:\Users\Public\Desktop folder.

The problem seems to be that these soft links are simply Window Explorer shortcuts and are not recognized by cmd prompts or batch files.

The only solution that I can see is to do the following -:


del "%allusersprofile%\Desktop\MyShortcut.lnk"


del "%PUBLIC%\Desktop\MyShortcut.lnk"

Is there any common solution for both OSes?

share|improve this question
I'm not aware of any such way due to the file structure changes between XP and Vista/7. One way you could achieve this functionality in a script is to get the OS version using ver, run it through a series of if/else checks, and then use goto to run the appropriate command. –  Garrett Nov 28 '11 at 5:02

2 Answers 2

up vote 3 down vote accepted

As stated by Garrett in comments of this question, the only solution I see is as follows:

SET Version=XP

VER | FINDSTR /IL "6.1." > NUL

IF %Version% EQU 7  (
 del "%PUBLIC%\Desktop\MyShortcut.lnk"
IF %Version% EQU XP  (
 del "%allusersprofile%\Desktop\MyShortcut.lnk"

One might note that according to this StackOverflow question, and a blog post by Raymond Chen, a dir of %allusersprofile%\Desktop\<directory> should give the proper results on both XP and 7, however in my experience it does not.

share|improve this answer

Good advice here which helped with my scenario.

  1. I created a batch file to remove the short-cuts

fixme.bat contains the following 3 lines:

del "C:\Users\Public\Desktop\gVim 7.4.lnk"
del "C:\Users\Public\Desktop\Cygwin64 Terminal.lnk"
  1. Right-mouse click on the batch file to pop-up the menu.

  2. Select "Run Elevated Privileges", enter your password.


You may also try "Run as administrator".

Good luck!

share|improve this answer
Hi Gooofy, thanks for the answer. Does this cover both XP and Vista/7, as stated in the original question? –  bertieb Jul 8 at 16:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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