In windows, how to mount folder as a drive

Solution 1:

You can use the subst command in Windows.

subst m: c:\foo

To make a persistent redirection, you can edit the registry. Add a string (REG_SZ) value to:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

Set the name of the value to the drive letter (e.g. M:), then the data to:

\??\C:\foo\foosub

This method will work across logins and reboots. I tested this on Windows 2008, so it should also work on Vista, XP, 2003 and 2000.

Solution 2:

Subst also works in Vista:

C:\Users\juan>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

.


Solution 3:

  • Right-click on the folder and select Sharing and Security
  • Select Share this folder
  • Give it a share name (eg- myshare)
  • hit Ok

Map a drive (M:) to \\yourcomputername\myshare


Solution 4:

From the command line:

subst M: C:\foo

This works in Windows XP, haven't tested it in other versions.


Solution 5:

Subst is the correct answer. You should be aware that subst is a per-session setting. It goes away when you log out and if you use runas to create a secondary logon context your subst-drive won't be there for those apps.

You can create a shortcut (.lnk) in your startup group to re-create those subst drives. The target property of the .lnk needs to be something like this:

C:\Windows\System32\cmd.exe /c subst S: C:\Some\Extremely\Obscure\Path\Of\My\Own\src

We use this technique to ensure that all developers build debug symbols with the same path from S:\

There is also a visual subst applet out there.

Tags:

Windows

Mount