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.

I created a symlink using mklink. Now I need to change it but I can't figure out how to delete it so I can recreate it correctly.

share|improve this question
2  
just delete it through windows explorer, deleting anything that has a little shortcut arrow on it will only remove the link regardless of whether you used mklink. –  Justin Buser Jan 18 '13 at 19:35
add comment

6 Answers

up vote 127 down vote accepted

Be very careful.

If you have a symbolic link that is a directory (made with mklink /d) then using del will delete all of the files in the target directory (the directory that the link points to), rather than just the link.

SOLUTION: rmdir on the other hand will only delete the directory link, not what the link points to.

share|improve this answer
19  
Having just accidentally done this (deleted the complete contents of the target folder), this an important tip. –  Simon Gillbee Aug 8 '11 at 21:10
2  
F**k! Me too... God bless backups... We should upvote this to "outvote" the accepted answer :) –  jitbit Mar 15 '12 at 10:56
1  
This answer is not entirely accurate. Del deletes files, not folders. Therefore, you would not use del to delete the link. –  AMissico Mar 12 '13 at 1:47
1  
But don't use rmdir in PowerShell. Wrap it in cmd first. See my answer below... –  northben May 13 '13 at 21:25
1  
How about if i delete it through windows explorer???? –  FireCat Aug 11 '13 at 16:49
add comment

For a symlink to a file, use del. For a symlink to a directory made with mklink /d, use rmdir.

share|improve this answer
add comment

mklink cannot be used to delete symbolic links. To remove a symbolic link, simply delete them as if you’re removing a normal file. For example, to delete the foo symbolic link created above, enter the following command:

If the link is a hard link to a directory:

C:\test>rmdir foo

or else, IF the link points to a file (as opposed to a dir)

C:\test>del foo

Source: http://www.mydigitallife.info/2007/05/22/create-symbolic-links-hard-links-and-directory-junctions-in-vista-with-mklink/

share|improve this answer
    
Ah, thanks, I was making it too hard. Eight more minutes till I can accept your answer. –  Ben V Jul 23 '10 at 23:28
1  
Just make sure you don't delete it with del /S or Explorer. –  Hello71 Jul 24 '10 at 0:12
1  
See eddyq's answer below because using del for a link made to a directory won't work and instead will attempt to delete teh contents of the folder. –  jpierson May 7 '12 at 13:48
add comment

To remove directory symbolic links created with mklink /d it is safe to just delete the symbolic link in explorer.

share|improve this answer
2  
+1 for telling people it is save to delete symbolic link through Windows Explorer. –  AMissico Mar 12 '13 at 1:45
add comment

In Powershell, don't use rmdir! Use cmd /c rmdir .\Target instead. I tested this myself and confirmed it here: http://kristofmattei.be/2012/12/15/powershell-remove-item-and-symbolic-links/

share|improve this answer
add comment

There is another solution tested by me and safe to use. just add to the real folder _ (example: foo become foo_) then simply delete your symbolik link, then remove _ from your true folder.

share|improve this answer
add comment

Your Answer

 
discard

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.