The SUBST command designates a virtual drive to represent a path. The drive so assigned and the path represented can be used synonymously.
To assign a virtual drive name to a path:
SUBST drive: path
To cancel a virtual drive designation:
SUBST drive: /D
To display a list of current virtual drives:
|drive:||The virtual drive to be created/released.|
|path||The physical path to be assigned to the virtual drive.|
- The SUBST command is typically used in three circumstances:
- To simplify referencing commonly used paths. Perhaps all data kept in the c:\program files\myfiles directory would be assigned to M:.
- To simplify (and shorten) PATH statements. If several paths to be included in the search path have parts of their structure in common, it can make things simpler if the common part is assigned a substitute drive letter.
- Some programs insist on running from a particular drive, even when that drive is not available or inconvenient to use. The path to be actually used can be assigned to the letter of the drive required.
- When assigning a path to a drive, the drive letter must be available. If it isn't, an error message is displayed stating that the specified drive is "an invalid parameter".
Reasons for a drive letter not being available include:
- The drive letter is already in use by a physical drive, other SUBSTed drive, or a hidden host drive of a compressed disk;
- LASTDRIVE has been set before the assigned drive letter. In Win 9x systems, the default setting for LASTDRIVE is z: but this can be modified in config.sys to any letter.
- A path that has been assigned to a drive letter via SUBST can still be accessed by its real name - ie. the SUBST command provides an alias, not a new name.
- The following commands will not work with virtual drives created using SUBST:
- The TRUENAME command can be used to display the real path of a drive that has been reassigned using the SUBST command.
- Windows Explorer will show both the virtual drive and the actual path in its file listings. Interestingly, files from the real path can be copied to files in the virtual drive (and vice versa) without problem. However, the same operation in Dos gives the error message that a file cannot be copied onto itself and no files are copied.
- If a SUBST drive is listed in a PATH statement, PATH will sometimes display the SUBST path, and sometimes the true path. The rules appear to be:
- If the "root" SUBST drive is added to the path, the SUBST drive is shown by PATH.
- If the SUBST drive plus a valid subdirectory is added to the path, the true path is shown by PATH.
- If the SUBST drive plus an invalid subdirectory is added to the path, PATH shows the SUBST drive.
- From time to time the question of whether SUBST should be used with Win 95/8 has been raised in the Dos related newsgroups. From everything I have seen the concensus is that there was (is?) a problem with Windows for Workgoups 3.11 but that's it. I haven't seen any reference to anyone having any problems working with SUBST in Win 95/8.
However, there is the point that the Win 9x registry will not automatically use the truename for a SUBSTed drive. If it were decided to SUBST the drive "P:" for "c:\windows\program files", programs could be installed to drive "P:" and everything would work just fine. But, if, at some time in the future, it was decided to reassign drive P: to, say, "d:\data\pictures", there would be some confusion in the registry - to say the least.
- For myself, I have found SUBST to be a very useful way of organising hard drives - it is much more flexible than partitioning (even with tools like Partition Magic). The major inconvenience is that the drive takes the volume name of the host. You can change it in Windows Explorer but that eventually filters back and changes the name of the host - I keep hoping that someone will write a little utility so that SUBSTed drives can somehow be given unique names!
To create a virtual drive called Z for the path "c:\data\docs\manuals\Dos":
SUBST z: c:\data\docs\manuals\Dos
Now, instead of typing the full path, the files in this directory can be reached simply by prefixing with "z:". A directory listing can be had with DIR z:, and to change the current directory one simply enters "z:" as though moving to a different drive.
|0||The command was executed without errors|
|1||An initialization error occurred. |
Such an error would generally caused by insufficient memory or disk space, or invalid drive name or syntax).
|File Name||Default Location||Dos Ver.||Win Ver.||Size||Date||Source|
Superscripts denote which same size files, if any, are identical (using FC).