Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some folder, say C:\foo I want to mount as drive M:\

In linux I would do this with a loop device.

share|improve this question
up vote 42 down vote accepted

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:


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.

share|improve this answer
Ah, +1. Forgot about the subst command, haven't used it in 10+ years! I don't think it's persistent though? Maybe I'm wrong, it's been a while... – squillman Jun 11 '09 at 22:01
Stick it in a logon or startup script then, and it'll be happily persistent. You can do this in the local group policy no need to go to domain level. – Le Comte du Merde-fou Jun 11 '09 at 22:15
Hey, that's nice! I didn't know about that, +1, I'll be using it.. – Greg Meehan Jun 11 '09 at 23:53
that's the way to go - unfortunately, there are several cases where a subst'ed drive doesn't get properly recognized. Don't be surprised if you get weird error messages from Windows at times, when you do stuff with your subst drive..... – marc_s Jun 12 '09 at 7:31
I added another method that is persistent. – Doug Luxem Jun 12 '09 at 19:44

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


share|improve this answer
  • 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

share|improve this answer

From the command line:

subst M: C:\foo

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

share|improve this answer
beat by the fastest gun – Ian Kelling Jun 11 '09 at 22:11
yep. shouldn't've tested the command first :p – goldPseudo Jun 11 '09 at 23:42

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.

share|improve this answer

You can do this in PowerShell as well. I use the following to set a drive to my Suvbversion working folder:

new-psDrive -name SVN -psprovider FileSystem -root 'c:\documents and settings\xxxx\my documents\subversion\adminscripts\trunk'

You can then access it as:

cd svn:
share|improve this answer
Please note that the PowerShell method doesn't make the "drive" available outside of PowerShell, so no Explorer access. You can do it with COM objects, but at that point just call SUBST anyway. – Ryan Fisher Jun 12 '09 at 0:36

Another way to do this, that perhaps plays a bit better with having it mounted on start, is to use the trick at (i.e. My Computer -> Tools -> Map Network Drive) and take advantage of the fact that your local machine is a network host; I have just mounted, for example,

\localhost\Users\me\Documents\My Dropbox\Portable Music

to M: this way. You might be able to use \localhost\C$\ to access everything, but I had some trouble with that here (although it's worked for me elsewhere).


share|improve this answer

If you need something which is cross-session you could look at running both an iSCSI target as well as iSCSI client on the same box. Obviously this is dependent on your OS as to whether you need anything 3rd party to achieve it.

share|improve this answer

use Subst Stick this into a .bat file

@echo off

Then save the batch file into the startup folder in the start menu. If you're on windows 8, you can find the startup folder by hitting Win+R then typing %appdata%\Microsoft\Windows\Start Menu\Programs\Startup

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.