6

I am using multiple installations of the same game (on Windows 10 Home), in order to have easier access to various addon/user configurations. The subfolders of each installation are Directory Junctions, pointing to the subfolders of the original game installation. They are created like this (starting from the parent folder of the folder where the game is installed - in my case, it's C:\Program Files):

rem The original game is installed in the MyCarGame folder
mkdir MyCarGame2
cd MyCarGame2
mklink /J GameData ..\MyCarGame\GameData
mklink /J Maps ..\MyCarGame\Maps

How to properly delete a Directory Junction (in this case "MyCarGame2\GameData" and "MyCarGame2\Maps"), to make sure I'm not removing the files/folders in it too?

Is it ok to delete them from a file manager like Windows Explorer, Total Commander or Free Commander?

This user for example reports that they deleted such a virtual folder and the result was that the content of the source folders was deleted (in my case "MyCarGame\GameData" and "MyCarGame\Maps").

Note: there is a similar question here: How to Delete a Junction by Using Command Line in Windows 7

3 Answers 3

7

I don't know about Total Commander and Free Commander but you have two ways to delete your junction without deleting the content of the source folder.

From Windows Explorer, go into MyCarGame2 and delete your junctions like any other folder. It doesn't delete the source, just the junction.

From Command Prompt:

cd MyCarGame2
rmdir GameData
rmdir Maps

From PowerShell (thanks to Brian Low's comments[1][2]):

cd MyCarGame2
cmd /c "rmdir GameData" 
cmd /c "rmdir Maps"
0
0

I know this post is old, but for anyone looking into this in 2023, you can use the following PS cmdlet-combination to remove a junction but not its contents :

$junction = Get-Item -Path <path_to_junction>
$junction.Delete()

That path is the actual junction path, not the parent path.

This can be condensed to :

(gi <path>).Delete()
0

Using Powershell

First make sure it is actually a junction:

(Get-ChildItem . -Force -Recurse | Where-Object { $_.LinkType -eq "Junction" -and $_.Attributes -match "ReparsePoint" }) | Select $_.FullName

Then delete (all) by adding on: | Remove-Item -Force -Recurse.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .