Subst
Encyclopedia
subst is a command
Command (computing)
In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell....

 on the DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

, IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

 OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

 and Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s used for substituting paths
Path (computing)
A path, the general form of a filename or of a directory name, specifies a unique location in a file system. A path points to a file system location by following the directory tree hierarchy expressed in a string of characters in which path components, separated by a delimiting character, represent...

 on physical and logical drives as virtual drive
Virtual drive
A virtual drive in computing is a device that to the operating system appears to be an ordinary physical disk drive, with disc images substituted for disc reading hardware through the use of software called a disk emulator...

s. In the past it has been used for revealing hidden drives on security-tense PC
Personal computer
A personal computer is any general-purpose computer whose size, capabilities, and original sales price make it useful for individuals, and which is intended to be operated directly by an end-user with no intervening computer operator...

s.

The Windows subst command is available in Windows 2000
Windows 2000
Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

 SP4 or later versions of the command line interpreter cmd.exe
Cmd.exe
Command Prompt is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems...

.

In Windows NT, subst uses DefineDosDevice to create the disk mappings.

Some versions of MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

 COMMAND.COM
COMMAND.COM
COMMAND.COM is the filename of the default operating system shell for DOS operating systems and the default command line interpreter on Windows 95, Windows 98 and Windows Me...

support the undocumented internal truename command which can display the "true name" of a file, by bypassing subst and assign filesystem mappings.

Usage

This is the Command Prompt output under Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...

:


C:\>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

drive1: Specifies a virtual drive to which you want to assign a path.
[drive2:]path Specifies a physical drive and path you want to assign to
a virtual drive.
/D Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.


This means that, for example, to map C:'s root to X: one would use subst X: C:\ at the command line. Upon doing this, a new drive called X: would appear under the My Computer Virtual Folder in Windows Explorer
Windows Explorer
This article is about the Windows file system browser. For the similarly named web browser, see Internet ExplorerWindows 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...

.

To unmap the drive, type in the following command at the command prompt:


C:\>subst [drive:] /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 F2
Function key
A function key is a key on a computer or terminal keyboard which can be programmed so as to cause an operating system command interpreter or application program to perform certain actions...

 ) 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:
  1. Delete the host's drive label;
  2. Create the proper registry keys for the SUBST drive letter;
  3. Create the proper registry keys for the host drive letter (optional, works around the host drive label override caveat);
  4. Re-create the SUBST drive to see label changes applied.

Persisting across reboots

Drive letters mapped in this way are not available during system startup for services nor do they persist across a reboot. However with a registry modification it is possible to assign a path to a drive letter during startup so it is available to system services and persists across a reboot.

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 the form: \??\C:\some\directory

or in form: \DosDevices\C:\some\directory

or in form: \Device\Mup\127.0.0.1\C$\some\directory

There are tools available to make the necessary changes for you.

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
The fstab file is a system configuration file commonly found on Unix systems. The fstab file typically lists all available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into the overall system's file system...

 on a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 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:
  1. run command: reg load hklm\$system C:\WINDOWS\system32\config\system
  2. run command: regedit.exe
  3. 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)
  4. close regedit.exe
  5. run command: reg unload hklm\$system (to complete the editing procedure)

Limitations

  • Not all Windows processes are able to use a drive letter created in this way.
  • Since (at least) Microsoft Windows XP SP2 Autorun.inf files present in the new drive letter are ignored; thus, AutoRun
    Autorun
    AutoRun and the companion feature AutoPlay are components of the Microsoft Windows operating system that dictate what actions the system takes when a drive is mounted....

    /AutoPlay
    AutoPlay
    AutoPlay, a feature introduced in Windows XP, 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 related to the AutoRun operating system feature...

     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
    Label (command)
    In computing, label is a command included with some operating systems . It is used to create, change, or delete a volume label on a logical drive, such as a hard disk partition or a floppy disk...

    command).

See also

  • Drive letter assignment
    Drive letter assignment
    Drive letter assignment is the process of assigning alphabetical identifiers to physical or logical disk drives or partitions in the root filesystem namespace; this usage is now mostly found in Microsoft operating systems...

  • List of DOS commands
  • Virtual drive
    Virtual drive
    A virtual drive in computing is a device that to the operating system appears to be an ordinary physical disk drive, with disc images substituted for disc reading hardware through the use of software called a disk emulator...

  • The join command will do the opposite of subst (take a drive letter and make it appear as a directory)

External links

  • fsutil hardlink create - creates a hard link
    Hard link
    In computing, a hard link is a directory entry that associates a name with a file on a file system. . The term is used in file systems which allow multiple hard links to be created for the same file. This has the effect of creating multiple names for the same file, causing an aliasing effect: e.g...

     (Windows 2000
    Windows 2000
    Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

     and later)
  • Microsoft.com - to create a symbolic link or hard link
    Hard link
    In computing, a hard link is a directory entry that associates a name with a file on a file system. . The term is used in file systems which allow multiple hard links to be created for the same file. This has the effect of creating multiple names for the same file, causing an aliasing effect: e.g...

     (Windows Vista
    Windows Vista
    Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

    and later)
  • SS64.com about "subst"
  • psubst tool for persistent mappings
  • Visual Subst — a GUI tool with persistent drive-mapping option.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK