How to make SUBST mapping persistent across reboots?

Well Wikipedia mentions:

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.

So you can associate paths with drive letters using subst. The Persistent SUBST command (psubst) software seems to be darn handy, and they provide a solution to run it from startup:

https://code.google.com/p/psubst/#Inconstancy

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.

In Windows, you can run the registry editor as follows:

  1. Start » Run... (or hit Win+R)
  2. Type: regedit
  3. In Windows Vista and above, UAC will pop up, click "Yes".

Installing it at HKEY_CURRENT_USER has the benefit of having different setups for each user. I prefer to stick the user space setup as long as a system service does not depend on the device.

REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"F Drive"="subst F: D:\\mount\\db"
"G Drive"="subst G: D:\\mount\\log"

Source: http://networkadminkb.com/KB/a446/how-to-use-drive-letters-mount-points-the-same-disk-drive.aspx


There's an answer in the page you linked to. You don't need the third party tool, you can do it with a simple registry entry, as detailed on that page.

Create a text file named 'mapdrive.reg' with these contents:

REGEDIT4 

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

Then should just be able to double-click on it to set up, no 3rd party tools needed.

Tags:

Windows