SUBST (DOS Command)
   HOME

TheInfoList



OR:

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, e ...
, 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 DOS is shorthand for the MS-DOS and IBM PC DOS family of operating systems. DOS may also refer to: Computing * Data over signalling (DoS), multiplexing data onto a signalling channel * Denial-of-service attack (DoS), an attack on a communicat ...
, 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 Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
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 a ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s used for substituting paths on physical and logical drives as
virtual drive Virtual disk and virtual drive are software components that emulate an actual disk storage device. Virtual disks and virtual drives are common components of virtual machines in hardware virtualization, but they are also widely used for various p ...
s.


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 ope ...
, the SUBST command was added with the release of MS-DOS 3.1. The command is similar to
floating drive In computer data storage, drive letter assignment is the process of assigning alphabetical identifiers to volumes. Unlike the concept of UNIX mount points, where volumes are named and located arbitrarily in a single hierarchical namespace, driv ...
s, 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 and ...
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 als ...
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 als ...
2.x,
Concurrent DOS Multiuser DOS is a Real-time operating system, real-time multi-user multi-tasking operating system for IBM Personal Computer, IBM PC-compatible microcomputers. An evolution of the older Concurrent CP/M-86, Concurrent DOS and Concurrent DOS 386 ...
,
Multiuser 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 by ...
, System Manager 7,
REAL/32 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 by ...
, as well as
DOS Plus DOS Plus (erroneously also known as DOS+) was the first operating system developed by Digital Research's OEM Support Group in Newbury, Berkshire, UK, first released in 1985. DOS Plus 1.0 was based on CP/M-86 Plus combined with the PCMODE ...
and
DR DOS 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 ...
(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
/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 system, legacy software and supporting embedded system ...
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, infor ...
. 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 commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
cmd.exe Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows (Windows NT family and Windows CE family), and ReactOS operating systems. On Windows CE .NET 4.2, Windo ...
. In
Windows NT Windows NT is a proprietary graphical operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems sc ...
, SUBST uses DefineDosDevice()
/code> to create the disk mappings. The
JOIN Join may refer to: * Join (law), to include additional counts or additional defendants on an indictment *In mathematics: ** Join (mathematics), a least upper bound of sets orders in lattice theory ** Join (topology), an operation combining two top ...
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 ope ...
COMMAND.COM COMMAND.COM is the default command-line interpreter for MS-DOS, Windows 95, Windows 98 and Windows Me. In the case of DOS, it is the default user interface as well. It has an additional role as the usual first program run after boot (init proc ...
support the undocumented internal
TRUENAME A true name is a name of a thing or being that expresses, or is somehow identical to, its true nature. The notion that language, or some specific sacred language, refers to things by their true names has been central to philosophical study as we ...
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 A path is a route for physical travel – see Trail. Path or PATH may also refer to: Physical paths of different types * Bicycle path * Bridle path, used by people on horseback * Course (navigation), the intended path of a vehicle * Desire p ...
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 released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Windows 2000 for high-end and ...
to associate a path with a drive letter: SUBST rive1:_[drive2:ath.html" ;"title="rive2:.html" ;"title="rive1: [drive2:">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 A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
: C:\>SUBST X: C:\ Upon doing this, a new drive called X: would appear under the ''My Computer''
virtual folder In computing, a virtual folder generally denotes an organizing principle for files that is not dependent on location in a hierarchical directory tree. Instead, it consists of software that coalesces results from a data store, which may be a databa ...
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 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, and ot ...
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 An autorun.inf file is a text file that can be used by the AutoRun and AutoPlay components of Microsoft Windows operating systems. For the file to be discovered and used by these component, it must be located in the root directory of a volume. ...
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 dir ...
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 cont ...
. 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 In computer data storage, drive letter assignment is the process of assigning alphabetical identifiers to volumes. Unlike the concept of UNIX mount points, where volumes are named and located arbitrarily in a single hierarchical namespace, driv ...
*
Floating drive In computer data storage, drive letter assignment is the process of assigning alphabetical identifiers to volumes. Unlike the concept of UNIX mount points, where volumes are named and located arbitrarily in a single hierarchical namespace, driv ...
*
Load drive In computer data storage, drive letter assignment is the process of assigning alphabetical identifiers to volumes. Unlike the concept of UNIX mount points, where volumes are named and located arbitrarily in a single hierarchical namespace, driv ...
*
NTFS symbolic link The NTFS file system defines various ways to redirect files and folders, e.g., to make a file point to another file or its contents without making a copy of it. The object being pointed to is called the target. Such file is called a hard or symbo ...


References


Further reading

* * *


External links


subst , Microsoft Docspsubst tool for persistent mappings
— a GUI tool with persistent drive-mapping option. {{Windows commands External DOS commands OS/2 commands