In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
,
SUBST
is a
command
Command may refer to:
Computing
* Command (computing), a statement in a computer language
* COMMAND.COM, the default operating system shell and command-line interpreter for DOS
* Command key, a modifier key on Apple Macintosh computer keyboards
...
on the
DOS,
IBM OS/2
OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 ...
,
Microsoft Windows and
ReactOS
ReactOS is a free and open-source operating system for amd64/ i686 personal computers intended to be binary-compatible with computer programs and device drivers made for Windows Server 2003 and later versions of Windows. ReactOS has been noted ...
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s used for substituting
paths on physical and logical drives as
virtual drives.
Overview
In
MS-DOS
MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
, the
SUBST
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
Digital Research, Inc. (DR or DRI) was a company created by Gary Kildall to market and develop his CP/M operating system and related 8-bit, 16-bit and 32-bit systems like MP/M, Concurrent DOS, FlexOS, Multiuser DOS, DOS Plus, DR DOS ...
origin, including
CP/M-86
CP/M-86 was a version of the CP/M operating system that Digital Research (DR) made for the Intel 8086 and Intel 8088. The system commands are the same as in CP/M-80. Executable files used the relocatable .CMD file format. Digital Research al ...
2.x,
Personal CP/M-86
CP/M-86 was a version of the CP/M operating system that Digital Research (DR) made for the Intel 8086 and Intel 8088. The system commands are the same as in CP/M-80. Executable files used the relocatable .CMD file format. Digital Research al ...
2.x,
Concurrent DOS
Multiuser DOS is a real-time multi-user multi-tasking operating system for IBM PC-compatible microcomputers.
An evolution of the older Concurrent CP/M-86, Concurrent DOS and Concurrent DOS 386 operating systems, it was originally developed b ...
,
Multiuser DOS,
System Manager 7,
REAL/32, as well as
DOS Plus and
DR DOS (up to 6.0).
DR DOS 6.0
DR-DOS (written as DR DOS, without a hyphen, in versions up to and including 6.0) is a disk operating system for IBM PC compatibles. Upon its introduction in 1988, it was the first DOS attempting to be compatible with IBM PC DOS and MS-D ...
includes an implementation of the command.
[DR DOS 6.0 User Guide Optimisation and Configuration Tips](_blank)
/ref> The command is also available in FreeDOS
FreeDOS (formerly Free-DOS and PD-DOS) is a free software operating system for IBM PC compatible computers. It intends to provide a complete MS-DOS-compatible environment for running legacy software and supporting embedded systems.
FreeDOS ca ...
and PTS-DOS
PTS-DOS (aka PTS/DOS) is a disk operating system, a DOS clone, developed in Russia by PhysTechSoft and Paragon Technology Systems.
History and versions
PhysTechSoft was formed in 1991 in Moscow, Russia by graduates and members of MIPT, i ...
. The Windows SUBST
command is available in supported versions of the command line interpreter
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
cmd.exe. In Windows NT
Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system.
The first version of Wi ...
, SUBST
uses DefineDosDevice()
/code> to create the disk mappings.
The JOIN
command is the "opposite" of SUBST
, because JOIN
will take a drive letter and make it appear as a directory.
Some versions of MS-DOS
MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
COMMAND.COM
support the undocumented internal TRUENAME
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 SUBST
, JOIN
and ASSIGN
filesystem mappings.
Syntax
This is the command syntax in Windows XP
Windows XP is a major release of Microsoft's Windows NT operating system. It was release to manufacturing, released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Wind ...
to associate a path with a drive letter:
SUBST rive1: [drive2:ath">rive2:.html" ;"title="rive1: [drive2:">rive1: [drive2:ath SUBST drive1: /D
Parameters
*drive1:
– Specify a virtual drive to which to assign a path.
*[drive2:]path
– Specify a physical drive and path to assign to a virtual drive.
*/D
– Delete a substituted (virtual) drive.
Examples
Mapping a drive
This means that, for example, to map C:'s root to X:, the following command would be used at the command-line interface:
C:\>SUBST X: C:\
Upon doing this, a new drive called X: would appear under the ''My Computer'' virtual folder in Windows Explorer
File Explorer, previously known as Windows Explorer, is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface for accessing the file ...
.
Unmapping a drive
To unmap drive X: again, the following command needs to by typed at the command prompt:
C:\>SUBST X: /D
Custom label
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.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\M\DefaultLabel\
(DefaultValue) = ''Your Drive Label''
"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:
# Delete the host's drive label;
# Create the proper registry keys for the SUBST drive letter;
# Create the proper registry keys for the host drive letter (optional, works around the host drive label override caveat);
# Re-create the SUBST drive to see label changes applied.
In addition the LABEL command is able to change the label name
LABEL : "Your label value"
Persisting across reboots
Drive letters mapped with the command are not available during system startup for services nor do they persist across a reboot.
Registry (DOS Devices)
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:
:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
The name should be "X:
" where ''X'' is the drive letter.
The value should be the path in one of the following NT Object Manager forms:
*\??\C:\some\directory
(preferred)
*\DosDevices\C:\some\directory
(long version of the former)
* \Device\Mup\127.0.0.1\C$\some\directory
(discouraged, as this goes through SMB share)
There are tools available to make the necessary changes for the user, including .
The relative to this thematic registry key is HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
. It defines mapping of drive letters into particular hard disk partitions, similar to /etc/fstab
fstab (after ''file systems table'') is a system file commonly found in the directory /etc on Unix and Unix-like computer systems. In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and ot ...
on a Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
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 "D:\Windows
" then you can edit the HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
key of Windows that is installed in a "C:\Windows
" folder, for an instance by doing the following actions:
# run command: reg load hklm\$system C:\WINDOWS\system32\config\system
# run command: regedit.exe
# edit registry key HKEY_LOCAL_MACHINE\$system\MountedDevices
(that represents the HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
registry key of the Windows instance that is installed in C:\WINDOWS
)
# close regedit.exe
# run command: reg unload hklm\$system
(to complete the editing procedure)
Importing reg file
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.
REGEDIT4
KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices"F:"="\\??\\D:\\Mount\\db"
"G:"="\\??\\D:\\Mount\\log"
After configuring the registry the computer must be rebooted for the changes to take effect.
Run on boot (batch)
Create a batch file to run the built-in SUBST
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:
@ECHO off
SUBST f: d:\mount\db
SUBST g: d:\mount\log
The user must log off and back on or the service must be restarted for the changes to take effect.
Run on boot (registry)
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
REGEDIT4
KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"F Drive"="SUBST f: d:\\mount\\db"
"G Drive"="SUBST g: d:\\mount\\log"
The computer must be rebooted for the changes to take effect.
Example of user logon
REGEDIT4
KEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"F Drive"="SUBST f: d:\\mount\\db"
"G Drive"="SUBST g: d:\\mount\\log"
The user must log off and back on for the changes to take effect.
Limitations
* Windows actions which act on disks at the physical layer are not possible.
* Since (at least) Microsoft Windows XP SP2 autorun.inf
files present in the new drive letter are ignored; thus, AutoRun/AutoPlay
AutoPlay, a feature introduced in Windows 98, examines newly discovered removable media and devices and, based on content such as pictures, music or video files, launches an appropriate application to play or display the content. It is closely rel ...
does not work on drive letters created in this way. In addition, assigning a custom icon or label to the drive letter created this way via autorun.inf
does not work. A custom label assigned to the drive letter created with subst
only appears if the source drive/volume does not have a volume label set (check and set with the label
A label (as distinct from signage) is a piece of paper, plastic film, cloth, metal, or other material affixed to a container or product, on which is written or printed information or symbols about the product or item. Information printed d ...
command).
* Starting with Windows Vista
Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, which was released five years before, at the time being the longest time span between successive releases of ...
, deleted files are immediately deleted permanently, and are not moved to the Recycle Bin
A recycling bin (or recycle bin) is a container used to hold recyclables before they are taken to recycling centers. Recycling bins exist in various sizes for use inside and outside homes, offices, and large public facilities. Separate con ...
. Prior to Windows Vista (in Windows XP, for example) files from substituted "disks" were moved to the Recycle Bin when deleted. A registry entry could be added to re-enable the Recycle Bin.
* Files or folders on drives created this way may have different access rights. Software installations may not work correctly, because the Config.msi directory created by the windows installer can not be accessed properly. Log files can not be written although the executing user has administrative rights.
See also
* Drive letter assignment
* Floating drive
* Load drive
* NTFS symbolic link
References
Further reading
*
*
*
External links
subst , Microsoft Docs
psubst tool for persistent mappings
— a GUI tool with persistent drive-mapping option.
{{Windows commands
External DOS commands
OS/2 commands