This guide helps in creating and managing symbolic links and custom drive mappings using the subst
command and registry modifications in Windows. It also provides examples of labeling drives and removing labels.
Symbolic links (symlinks) are a powerful feature in Windows that allow you to map directories or files to other locations, providing flexibility in file management. Below are some useful commands and configurations for creating and managing symbolic links and drive mappings.
Example Commands for Subst and Symlinks
-
Create a virtual drive using
subst
This command maps a folder to a drive letter.subst G: C:\gitroot
- This maps the folder
C:\gitroot
to the virtual driveG:
.
- This maps the folder
-
Registry Path for Symlink Drive Mapping (Win10)
In Windows 10, symbolic drive mappings are stored in the registry. Use the following registry key to manage symbolic drives:Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
- Add a new entry under
DOS Devices
:- Value:
G:
- Data:
\??\C:\gitroot
- Value:
This ensures that the symbolic link is persistent across system restarts.
FYI: these registry entries vanish with every major windows update. Maybe keep a batch file with your commands handy.
- Add a new entry under
Personal System Setup
For your own system, you can create multiple symbolic links and drive mappings. Below are examples of such mappings:
-
Mapping to Specific Folders
Create symbolic links for various folders by using thesubst
command:subst D: C:\_D subst P: D:\_portables subst G: D:\_gitroot subst I: D:\_apps subst V: D:\vsonline
These commands create virtual drives
D:
,P:
,G:
,I:
, andV:
mapping them to specific directories on theD:
drive. -
Remove a Subst Mapping
To remove a mapped drive, use the/D
flag with thesubst
command:subst I: /D
This removes the mapping for the drive
I:
. -
Labeling Drives
You can also label drives to make them easier to identify. For example:label D: data
- This labels the drive
D:
with the namedata
.
- This labels the drive
-
Remove Drive Label
To remove the label of a drive, simply open the drive (e.g., typeC:
) in Windows Explorer, right-click, and chooseLabel
. You will be prompted to remove the existing label.