In computing, <code>SUBST</code> is a command on the DOS, IBM OS/2, Microsoft Windows and ReactOS operating systems used for substituting paths on physical and logical drives as virtual drives.
In MS-DOS, the <code>SUBST</code> command was added with the release of MS-DOS 3.1. The command is similar to floating drives, a more general concept in operating systems of Digital Research origin, including CP/M-86 2.x, Personal CP/M-86 2.x, Concurrent DOS, Multiuser DOS, System Manager 7, REAL/32, as well as DOS Plus and DR DOS (up to 6.0). DR DOS 6.0 includes an implementation of the command. The command is also available in FreeDOS and PTS-DOS. The Windows <code>SUBST</code> command is available in supported versions of the command line interpreter cmd.exe. In Windows NT, <code>SUBST</code> uses <code>DefineDosDevice()</code> to create the disk mappings.
The <code>JOIN</code> command is the "opposite" of <code>SUBST</code>, because <code>JOIN</code> will take a drive letter and make it appear as a directory.
Some versions of MS-DOS <code>COMMAND.COM</code> support the undocumented internal <code>TRUENAME</code> command which can display the "true name" of a file, i.e. the fully qualified name with drive, path, and extension, which is found possibly by name only via the PATH environment variable, or through <code>SUBST</code>, <code>JOIN</code> and <code>ASSIGN</code> filesystem mappings.
This is the command syntax in Windows XP to associate a path with a drive letter:
SUBST [drive1: [drive2:]path] SUBST drive1: /D
This means that, for example, to map C:'s root to X:, the following command would be used at the command-line interface:
Upon doing this, a new drive called X: would appear under the My Computer virtual folder in Windows Explorer.
To unmap drive X: again, the following command needs to by typed at the command prompt:
A custom label can be assigned to a drive letter created in this way by way of a registry key, which can be created by renaming (select "rename" from the drive letter context menu or press ) the SUBST drive in Windows Explorer/My Computer.
<code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\M\DefaultLabel\</code>
<code>(DefaultValue) = Your Drive Label</code>
"M" represents the drive letter to assign a custom label to.
However, labels created for SUBST drives in this manner are overridden by the label of the host drive/partition: the custom labels are only used if the host drive has no label. One may then:
Note that the LABEL command is NOT able to change the label name of a drive letter created using subst. LABEL is one of several commands that only work on physical drives.
Drive letters mapped with the command are not available during system startup for services nor do they persist across a reboot.
The DOS Devices mechanism that underlies subst can be set in registry. This way, the mapped drives are usable immediately during startup.
Create a new registry entry "String Value" in the following key:
The name should be "<code>X:</code>" where X is the drive letter.
The value should be the path in one of the following NT Object Manager forms:
There are tools available to make the necessary changes for the user, including .
The relative to this thematic registry key is <code>HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices</code>. It defines mapping of drive letters into particular hard disk partitions, similar to /etc/fstab on a Unix system. It also can be edited manually, but only at that time while that particular installed Window operation system is "inactive". So that, for example, if you currently boot from "<code>D:\Windows</code>" then you can edit the <code>HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices</code> key of Windows that is installed in a "<code>C:\Windows</code>" folder, for an instance by doing the following actions:
The easiest way to do this is to create a registry file (.reg), and double click the file to import the settings into the registry.
Here is an example registry file.
After configuring the registry the computer must be rebooted for the changes to take effect.
Create a batch file to run the built-in <code>SUBST</code> command to create a virtual drive letter for the existing mount points and place it in the user accounts startup folder.
This is not preferred, as the mapping only appears at the end of user logon.
Here is an example:<br />
The user must log off and back on or the service must be restarted for the changes to take effect.
Edit the registry to run the built-in subst command during computer startup or user logon by leveraging the appropriate Run registry key. The easiest way to do this is to create a registry file (.reg), and double click the file to import the settings into the registry.
This is not preferred, as the mapping only appears at the end of bootup.
Example to run during computer boot
The computer must be rebooted for the changes to take effect.
Example of user logon
The user must log off and back on for the changes to take effect.