122

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

Nord
  • 1,345

4 Answers4

157

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

grawity
  • 501,077
35

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

fsutil reparsepoint delete <<PATH>>
Spig
  • 471
13

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

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

0xC0000022L
  • 7,544
  • 10
  • 54
  • 94
Jeff G
  • 131
-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
  • 236
  • 1
  • 8