116

I believe in Windows Vista, we could use linkd command. However, I cannot find this command in Windows 7. I know I can use Windows Explorer and delete the junction, but I wonder if this can be done in Command Prompt.

I can use mklink command to create a junction from a Command Prompt, so, what is the opposite of it (something like linkd)?

0

4 Answers 4

146

Delete junctions with rmdir (rd). Works in all Windows versions.

12
  • 2
    @gravity, thanks! rd works while del does not.
    – Nord
    May 19, 2011 at 5:45
  • 6
    As a Linux user I really struggled to find this. Thanks so much! Oct 28, 2011 at 1:05
  • 5
    @Vi3GameHkr: If only Linux started using ntfs without third-party software... /// Windows does use swap, it just calls it "paging file".
    – user1686
    Sep 7, 2012 at 13:05
  • 21
    This does not work in Powershell - it will follow the junction and delete all files. Use cmd /c "rmdir mydir".
    – Brian Low
    Sep 15, 2014 at 6:00
  • 3
    @grawity Seems to for me: gist.github.com/brianlow/0d5d2070c87c378454d7
    – Brian Low
    Sep 16, 2014 at 1:46
28

In my experience fsutil reparsepoint will take care of some cases where rmdir gives Access Denied.

fsutil reparsepoint delete <<PATH>>
3
  • I had a junction point that was giving access denied if I used rmdir. Using this method, the junction point becomes a regular folder with read-only attribute. attrib -R and rmdir finally finished the job.
    – Codism
    Oct 28, 2016 at 15:06
  • Absolute legend! was getting "Unspecified Error" or Access Denied" when attempting to delete a stale WindowsApps directory in explorer after much messing around with rmdir, del, and a few other attempts I realised a few contained directories were actually junctions despite having ownership, granting permissions, removing read only attribute, nothing wanted to remove them however your answer worked! Thank you :)
    – Brian
    Aug 26, 2020 at 13:50
  • This works but it will leave the actual mount point dir behind, as an empty dir. The latter has to be deleted separately.
    – Fizz
    Feb 8 at 5:52
11

Use the -d flag on junction (junction -d ...)

Source: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

1
  • 2
    You had to mention that junction is a separate utility that needs to be downloaded. Nov 11, 2020 at 17:21
-1
linkd source /D

will delete the junction point (the link) without deleting on destination

1
  • 8
    Read the question. This command doesn't exist in Windows 7.
    – Aaronaught
    Nov 24, 2013 at 17:27

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.