Other methods for Persisting across reboots Method 1 Method 2 Method 3
Limitations
See also
References
External links
{{Selfref|Within Wikipedia, subst: may refer to substitution.}}{{refimprove|date=September 2014}}{{Infobox Software | name = subst | logo = | screenshot = | screenshot size = | caption = | developer = Microsoft, IBM, ReactOS Contributors | released = {{Release year|df=yes|1985}} | latest release version = | latest release date = | operating system = DOS, OS/2, Microsoft Windows, ReactOS | genre = Command | license = | website = }}
In computing, SUBST 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.
Overview
In MS-DOS SUBST 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).
The command is also available in FreeDOS[1] and PTS-DOS.[2] The FreeDOS version was developed by Steffen Kaiser.[3]
The Windows SUBST command is available in supported versions of the command line interpreter CMD.EXE.[4] In Windows NT, SUBST uses DefineDosDevice() 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 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.
Usage
{{Guidebook|date=July 2016}}
This is the Command Prompt output under Windows XP:
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.
Unmapping the Drive
To unmap the drive, type in the following command at the command prompt:
C:\\>SUBST [drive:] /D
Custom label
A custom label can{{Citation needed|date=January 2009}} 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 {{keypress|F2}}) 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 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:
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 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 "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)
Other methods for Persisting across reboots
Method 3 is the recommended approach, but the others may work as well.
Method 1
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.
Here is an example:
The user must log off and back on or the service must be restarted for the changes to take effect.
Method 2
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.
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.
Method 3
Edit the registry to create virtual drives to the desired mount points across reboots for all users by leveraging the DOS Devices 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.
Here is an example registry file.
After configuring the registry the computer must be rebooted for the changes to take effect.
Limitations
Windows actions which act on disks at the physical layer are not possible.[5]
Since (at least) Microsoft Windows XP SP2 autorun.inf files present in the new drive letter are ignored; thus, AutoRun/AutoPlay 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 command).
Starting with Windows Vista, deleted files are immediately deleted permanently, and are not moved to the Recycle Bin. Prior to Windows Vista (in Windows XP, for example) files from substituted "disks" were moved to the Recycle Bin when deleted.
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
1. ^http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-base.html 2. ^{{cite web |title=PTS-DOS 2000 Pro User Manual |publisher=Paragon Technology GmbH |location=Buggingen, Germany |date=1999 |url=http://download.paragon-software.com/doc/manual_dos_eng.pdf |access-date=2018-05-12 |dead-url=no |archive-url=https://web.archive.org/web/20180512094512/http://download.paragon-software.com/doc/manual_dos_eng.pdf |archive-date=2018-05-12}} 3. ^http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/swsubst.html 4. ^[https://technet.microsoft.com/en-us/library/bb491006.aspx Microsoft TechNet Subst article] 5. ^Microsoft.com
External links
[https://ss64.com/nt/subst.html SS64.com about "subst"]
[https://github.com/ildar-shaimordanov/psubst psubst tool for persistent mappings]
Visual Subst — a GUI tool with persistent drive-mapping option.