How to Delete a Junction by Using Command Prompt in Windows 7
168,774
Solution 1
Delete junctions with rmdir
(rd
). Works in all Windows versions.
Solution 2
In my experience fsutil reparsepoint
will take care of some cases where rmdir
gives Access Denied.
fsutil reparsepoint delete <<PATH>>
Solution 3
Use the -d
flag on junction
(junction -d ...
)
Source: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
Related videos on Youtube
Author by
Nord
Updated on September 18, 2022Comments
-
Nord almost 2 years
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 likelinkd
)? -
Nord about 13 years@gravity, thanks! rd works while del does not.
-
Nord about 13 yearsOwh.. I mean @grawity (not @gravity) in my previous comment. Please accept my apology.
-
Jonathon Reinhart over 12 yearsAs a Linux user I really struggled to find this. Thanks so much!
-
mejdev almost 12 years@JonathonReinhart I resonate well with that. If only Windows started used swap and ext4 without third-party software!
-
user1686 almost 12 years@Vi3GameHkr: If only Linux started using ntfs without third-party software... /// Windows does use swap, it just calls it "paging file".
-
Adambean almost 11 yearsThanks :) This works fine. I didn't want to do it in Explorer as it may delete the target stuff too.
-
Aaron Silverman about 10 yearsFor some reason this didn't work for me. I had to do the following in a console with administrator privileges first: fsutil reparsepoint delete C:\Path\To\Junction
-
Brian Low almost 10 yearsThis does not work in Powershell - it will follow the junction and delete all files. Use cmd /c "rmdir mydir".
-
user1686 almost 10 years@BrianLow: Wat.
-
Brian Low almost 10 years@grawity Seems to for me: gist.github.com/brianlow/0d5d2070c87c378454d7
-
user2995603 over 7 yearsI 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.
-
Sergey over 5 yearsrmdir tells dir is not empty for junction
-
elig about 4 yearswhen the linked directory is invalid
rd
returned an error butdel
worked -
Brian almost 4 yearsAbsolute 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 :)
-
Damn Vegetables over 3 yearsYou had to mention that
junction
is a separate utility that needs to be downloaded. -
Fizz over 2 yearsThis works but it will leave the actual mount point dir behind, as an empty dir. The latter has to be deleted separately.