118

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)?

Mathieu K.
  • 287
  • 2
  • 13
Nord
  • 1,305
  • 2
  • 9
  • 7

5 Answers5

149

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

Cristian Ciupitu
  • 5,513
  • 2
  • 37
  • 47
u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
32

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

fsutil reparsepoint delete <<PATH>>
Cristian Ciupitu
  • 5,513
  • 2
  • 37
  • 47
Spig
  • 431
  • 4
  • 5
  • 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 '16 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 '20 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 08 '22 at 05:52
13

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

Source: https://learn.microsoft.com/en-us/sysinternals/downloads/junction

0xC0000022L
  • 6,819
  • 10
  • 50
  • 82
Jeff G
  • 131
  • 1
  • 3
-1

I ran into pretty severe issue where none of the above worked (fsutil or sysinternal junction command) because I had moved WindowsApps folder to different drive and then tried to use that drive on another computer. Once junctions don't have valid pointer, it seems they get impossible to be deleted. One thing that seems to worked was using WSL (type command bash) from elevated Windows terminal and then do sudo rm -rf \mnt\e\WindowsApps\. You can also try to turn off Gaming Services in Services if you keep getting Access Denied (alternatively, login to console at startup). Another useful app towards this task is LockHunter which allows to mark files to be deleted at startup.

Shital Shah
  • 206
  • 1
  • 7
-1
linkd source /D

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

James Mertz
  • 26,224
  • 41
  • 111
  • 163
Nicolas
  • 39
  • 1