Archive for February, 2012

REGISTRY ENTRY FOR SUBST

Subst

Associates a path with a drive letter. Used without parameters, subst displays the names of the virtual drives in effect.

Syntax

subst [drive1: [drive2:]Path]

subst drive1: /d

 

Parameters

drive1: : Specifies the virtual drive to which you want to assign a path.

drive2: : Specifies the physical drive that contains the specified path (if different from the current drive).

Path : Specifies the path that you want to assign to a virtual drive.

/d : Deletes a virtual drive.

/? : Displays help at the command prompt.

 

Remarks

The following commands do not work, or should not be used, on drives used in the subst command:

  • chkdsk
  • diskcomp
  • diskcopy
  • format
  • label
  • recover

 

The drive1   parameter must be within the range specified by the lastdrive command.   If not, substdisplays the following error message:Invalid parameter –   drive1:Examples

To create a virtual   drive Z for the path B:\User\Betty\Forms, type:

subst z:   b:\user\betty\forms

Now, instead of   typing the full path, you can reach this directory by typing the letter of   the virtual drive, followed by a colon, as follows:

z:

Divide and power

Since oldest times   in Windows there is admirable feature to map some path with name of a virtual   drive using the SUBST command. This feature makes the simpler an access to   objects on a disk. It means a usage of name of a virtual drive instead of a   long path. For example, the following command is used to create virtual drive   Z for the path C:\Documents and Settings\All Users\Shared Documents:

subst Z: “C:\Documents and Settings\All Users\Shared Documents”

So to reach targets   in this folder it does not need to type the full path or go over a tree of   folders in the Explorer window. To select the Z: drive is enough.

Do we need it?

There is several   certain examples when this feature is needful:

Temporary stub when   the physical drive is missing;

Operational system   limitation for the size of filename (256 characters);

Working of some   application within own space;

Emulation of other   operational systems.

How does this work?

Create new virtual   drive:

subst Z: “C:\Documents and Settings\All Users\Shared Documents”

Delete virtual   drive:

subst Z: /D

Print a list of   existing drives:

subst

Shortcomings

Indefinite format

There is strong   agreement about a correct typing of the substituted path:

a path should not be   trailed by a backslash;

the root path should   be ended by a backslash.

For example, these   are correct

subst Z: “C:\Documents and Settings\All Users\Shared Documents”
subst Z: C:\

But these are   incorrect:

subst Z: “C:\Documents and Settings\All Users\Shared Documents\”
subst Z: C:

Inconstancy

However restart of a   system destroys a virtual disk. What to do? A disk can be created after   startup. But what to do, when a disk is needed on early steps of a startup?   For example, to run services? There is system feature to start a virtual disk   from the system registry:

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session   Manager\DOS Devices]
“Z:”=”\\??\\C:\\Documents   and Settings\\All Users\\Shared Documents

It is enough to   create a text file with the extension .REG and run it. When the next starting   up of a system, the virtual disk will be exist at logon. It needs to define a   name of disk and path. Note that each backslash in the path is doubled.