Misplaced Pages

SUBST: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 07:32, 28 May 2021 editGhostInTheMachine (talk | contribs)Extended confirmed users, Page movers85,280 edits Importing Wikidata short description: "Command on the DOS, IBM OS/2, Microsoft Windows and ReactOS operating systems" (Shortdesc helper)← Previous edit Latest revision as of 20:35, 27 August 2024 edit undoCitation bot (talk | contribs)Bots5,408,427 edits Add: date, title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by Grimes2 | #UCB_webform 1179/1433 
(23 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{Short description|Command on the DOS, IBM OS/2, Microsoft Windows and ReactOS operating systems}} {{Short description|Operating system command}}
{{Self reference|Within Misplaced Pages, '''<code>subst:</code>''' may refer to ].}}
{{Infobox software {{Infobox software
| name = subst | name = subst
Line 18: Line 17:
}} }}
{{How-to|date=January 2021}} {{How-to|date=January 2021}}
In ], '''<code>SUBST</code>''' is a ] on the ], ] ],<ref>http://www.jatomes.com/Help/Os2Cmd.php#SUBST</ref> ] and ]<ref>https://github.com/reactos/reactos/blob/master/base/system/subst/subst.c</ref> ]s used for substituting ] on physical and logical drives as ]s. In ], '''<code>SUBST</code>''' is a ] on the ], ] ],<ref>{{cite web |url=http://www.jatomes.com/Help/Os2Cmd.php#SUBST |title=JaTomes Help - OS/2 Commands |website=www.jatomes.com |url-status=dead |archive-url=https://web.archive.org/web/20190414130029/http://www.jatomes.com/Help/Os2Cmd.php |archive-date=2019-04-14}}</ref> ] and ]<ref>{{cite web|url=https://github.com/reactos/reactos/blob/master/base/system/subst/subst.c|title=Reactos/Reactos|website=]|date=22 November 2021}}</ref> ]s used for substituting ] on physical and logical drives as ]s.


==Overview== ==Overview==
In ], the <code>SUBST</code> command was added with the release of MS-DOS 3.1.<ref name="RUNNINGMSDOS">{{Cite book|author-last=Wolverton|author-first=Van|title=Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition|date=2003|publisher=]|isbn=0-7356-1812-7}}</ref> The command is similar to ]s, a more general concept in operating systems of ] origin, including ] 2.x<!-- because of BDOS version -->, ] 2.x, ], ]<!-- all versions -->, ] 7, ]<!-- all versions -->, as well as ]<!-- all versions --> and ] (up to 6.0). ] includes an implementation of the {{code|SUBST}} command.<ref name="drdos6userguide"></ref> The command is also available in ]<ref>http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-base.html</ref> and ].<ref> In ], the <code>SUBST</code> command was added with the release of MS-DOS 3.1.<ref name="RUNNINGMSDOS">{{Cite book|author-last=Wolverton|author-first=Van|title=Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition|date=2003|publisher=]|isbn=0-7356-1812-7}}</ref> The command is similar to ]s, a more general concept in operating systems of ] origin, including ] 2.x<!-- because of BDOS version -->, ] 2.x, ], ]<!-- all versions -->, ] 7, ]<!-- all versions -->, as well as ]<!-- all versions --> and ] (up to 6.0). ] includes an implementation of the {{code|SUBST}} command.<ref name="drdos6userguide"></ref> The command is also available in ]<ref>{{cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-base.html |title=FreeDOS 1.2 Updates Group - FreeDOS Base |publisher=Ibiblio.org |date= |accessdate=2022-09-04}}</ref> and ].<ref>
{{cite web |title=PTS-DOS 2000 Pro User Manual |publisher=] |location=Buggingen, Germany |date=1999 |url=http://download.paragon-software.com/doc/manual_dos_eng.pdf |access-date=2018-05-12 |url-status=live |archive-url=https://web.archive.org/web/20180512094512/http://download.paragon-software.com/doc/manual_dos_eng.pdf |archive-date=2018-05-12}}</ref> The Windows <code>SUBST</code> command is available in supported versions of the ] ].<ref></ref> In ], <code>SUBST</code> uses <code></code> to create the disk mappings. {{cite web |title=PTS-DOS 2000 Pro User Manual |publisher=] |location=Buggingen, Germany |date=1999 |url=http://download.paragon-software.com/doc/manual_dos_eng.pdf |access-date=2018-05-12 |url-status=live |archive-url=https://web.archive.org/web/20180512094512/http://download.paragon-software.com/doc/manual_dos_eng.pdf |archive-date=2018-05-12}}</ref> The Windows <code>SUBST</code> command is available in supported versions of the ] ].<ref>{{Cite web|url=https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb491006(v=technet.10)|title=Subst|website=learn.microsoft.com|date=11 September 2009 }}</ref> In ], <code>SUBST</code> uses <code></code> to create the disk mappings.


The <code>]</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. The <code>]</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.
Line 38: Line 37:
*<code>'''path'''</code> – Specify a physical drive and path to assign to a virtual drive. *<code>'''path'''</code> – Specify a physical drive and path to assign to a virtual drive.
*<code>'''/D'''</code> – Delete a substituted (virtual) drive. *<code>'''/D'''</code> – Delete a substituted (virtual) drive.

Using the <code>SUBST</code> command with no parameters will display a list of current virtual drives.


==Examples== ==Examples==
Line 73: Line 70:
# Re-create the SUBST drive to see label changes applied. # Re-create the SUBST drive to see label changes applied.


In addition the LABEL command is able to change the label name Note that the LABEL command is NOT able to change the label name of a drive letter created using subst.<ref>{{cite web | url=https://superuser.com/a/198509/557294 | title=Change network drive label by command line }}</ref>
LABEL is one of several commands that only work on physical drives.<ref>{{cite web | url=https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/subst | title=Subst | date=3 February 2023 }}</ref>

<code>LABEL <Your Drive Letter>: "Your label value"</code>


==Persisting across reboots== ==Persisting across reboots==
Drive letters mapped with the command are not available during system startup for services nor do they persist across a reboot. Drive letters mapped with the command are not available during system startup for services nor do they persist across a reboot.


=== Registry (DOS Devices) === === 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. 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:<br/> Create a new registry entry ''"String Value"'' in the following key:
:<code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices</code> :<code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices</code>


Line 98: Line 94:
# run command: <code>reg load hklm\$system C:\WINDOWS\system32\config\system</code> # run command: <code>reg load hklm\$system C:\WINDOWS\system32\config\system</code>
# run command: <code>regedit.exe</code> # run command: <code>regedit.exe</code>
# edit registry key <code>HKEY_LOCAL_MACHINE\$system\MountedDevices</code> <br/> (that represents the <code>HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices</code> registry key of the Windows instance that is installed in <code>C:\WINDOWS</code>) # edit registry key <code>HKEY_LOCAL_MACHINE\$system\MountedDevices</code> <br /> (that represents the <code>HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices</code> registry key of the Windows instance that is installed in <code>C:\WINDOWS</code>)
# close <code>regedit.exe</code> # close <code>regedit.exe</code>
# run command: <code>reg unload hklm\$system</code> (to complete the editing procedure) # run command: <code>reg unload hklm\$system</code> (to complete the editing procedure)
Line 106: Line 102:


Here is an example registry file. Here is an example registry file.
<syntaxhighlight lang="reg"> <syntaxhighlight lang="registry">
REGEDIT4 REGEDIT4


Line 122: Line 118:


Here is an example:<br /> Here is an example:<br />
<syntaxhighlight lang="dos"> <syntaxhighlight lang="dosbatch">
@ECHO off @ECHO off
SUBST f: d:\mount\db SUBST f: d:\mount\db
Line 135: Line 131:


Example to run during computer boot Example to run during computer boot
<syntaxhighlight lang="reg"> <syntaxhighlight lang="registry">
REGEDIT4 REGEDIT4


Line 146: Line 142:
Example of user logon Example of user logon
<syntaxhighlight lang="reg"> <syntaxhighlight lang="registry">
REGEDIT4 REGEDIT4


Line 157: Line 153:


==Limitations== ==Limitations==
* Windows actions which act on disks at the physical layer are not possible.<ref></ref> * Windows actions which act on disks at the physical layer are not possible.<ref>{{Cite web|url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx|title=Microsoft.com|website=] }}</ref>
* Since (at least) Microsoft Windows XP SP2 <code>]</code> files present in the new drive letter are ignored; thus, ]/] 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 <code>autorun.inf</code> does not work. A custom label assigned to the drive letter created with <code>subst</code> only appears if the source drive/volume does not have a volume label set (check and set with the <code>]</code> command). * Since (at least) Microsoft Windows XP SP2 <code>]</code> files present in the new drive letter are ignored; thus, ]/] 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 <code>autorun.inf</code> does not work. A custom label assigned to the drive letter created with <code>subst</code> only appears if the source drive/volume does not have a volume label set (check and set with the <code>]</code> command).
* Starting with ], deleted files are immediately deleted permanently, and are not moved to the ]. 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.<ref>https://superuser.com/a/1475575/502161</ref> * Starting with ], deleted files are immediately deleted permanently, and are not moved to the ]. 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.<ref>{{cite web|url=https://superuser.com/a/1475575/502161|title = Windows - How to make SUBST mapping persistent across reboots?}}</ref>
* 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. * 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.


Line 189: Line 185:
] ]
] ]
]

Latest revision as of 20:35, 27 August 2024

Operating system command
subst
Developer(s)Microsoft, IBM, Digital Research, ReactOS Contributors
Initial release1985, 38–39 years ago
Operating systemMS-DOS, PC DOS, SISNE plus, OS/2, eComStation, ArcaOS, DR DOS, ROM-DOS, PTS-DOS, FreeDOS, Windows, ReactOS
PlatformCross-platform
TypeCommand
Websitedocs.microsoft.com/en-us/windows-server/administration/windows-commands/subst
This article contains instructions, advice, or how-to content. Please help rewrite the content so that it is more encyclopedic or move it to Wikiversity, Wikibooks, or Wikivoyage. (January 2021)

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, 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 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 SUBST command. The command is also available in FreeDOS and PTS-DOS. The Windows SUBST command is available in supported versions of the command line interpreter cmd.exe. 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.

Syntax

This is the command syntax in Windows XP to associate a path with a drive letter:

SUBST path]
SUBST drive1: /D

Parameters

  • drive1: – Specify a virtual drive to which to assign a path.
  • 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.

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 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:

  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.

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.

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 psubst.

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:

  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)

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
"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
"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
"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 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. 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

References

  1. "JaTomes Help - OS/2 Commands". www.jatomes.com. Archived from the original on 2019-04-14.
  2. "Reactos/Reactos". GitHub. 22 November 2021.
  3. Wolverton, Van (2003). Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. ISBN 0-7356-1812-7.
  4. DR DOS 6.0 User Guide Optimisation and Configuration Tips
  5. "FreeDOS 1.2 Updates Group - FreeDOS Base". Ibiblio.org. Retrieved 2022-09-04.
  6. "PTS-DOS 2000 Pro User Manual" (PDF). Buggingen, Germany: Paragon Technology GmbH. 1999. Archived (PDF) from the original on 2018-05-12. Retrieved 2018-05-12.
  7. "Subst". learn.microsoft.com. 11 September 2009.
  8. "Change network drive label by command line".
  9. "Subst". 3 February 2023.
  10. "Microsoft.com". Microsoft.
  11. "Windows - How to make SUBST mapping persistent across reboots?".

Further reading

External links

Windows command-line programs and shell builtins
File system navigation
File management
Archiving
Disk management
Processes
Registry
User environment
File contents
Scripting
Networking
Maintenance and care
Boot management
Software development
Miscellaneous
Categories: