Quick Tip: Assign a Drive Letter to a Folder (Windows)

Did you know that Microsoft Windows allows you to define virtual disk drives? Any drive letter that is not currently used to represent a physical drive can be defined as a virtual drive. What is a virtual drive? It’s a folder of a physical drive that acts like it is a separate drive, unto itself. Some reasons you may a want, or need, to do this are:

  • As a handy shortcut.
  • Because some software requires it.
  • In a batch file, so that the path only needs to be referenced once at the top of the batch file, and therefore could be easily changed later, if need be.

Pretend that you have a file folder called C:\data\word_docs, that you use it constantly, and that you would like to refer to it with a shortcut of W:. Open up a command prompt window and issue the following command:

SUBST w: C:\\data\\word_docs

SUBST is short for substitute. (DOS commands are case-insensitive, so you could enter it as “subst” as well.) So, now, W:\intro.doc is the same thing as C:\data\word_docs\intro.doc — two different ways to refer to the same file.

If you ever move the folder, and want to change the shortcut, just reissue the SUBST command:

SUBST w: D:\\new_location\\word_docs

Virtual drive definitions are permanent, until explicitly released. If and when you decide you’re not using it anymore, the command to remove the association is:


To find out what virtual drives are currently defined, just type SUBST on a line by itself:


Important: Be aware that when deleting any files via a virtual drive letter reference, the files are deleted immediately, bypassing the recycle been. So, in the example above, if you were to delete C:\data\word_docs\intro.doc, it will go to the recycle bin, but if you were to delete it by referring to it as W:\intro.doc, then it would not be recycled.

Related articles:

Trackbacks & Pings


  1. Please check this tip too to quickly access any folder using run

  2. You say that virtual drives are permanent until explicitly released. You should mention that shutting down windows releases all virtual drives. In order to have them truly be permanent, the easiest way is to make a batch file that runs the SUBST command and put it in your startup folder.

    See this article:



  3. If you have a network you can just map it. I do it all the time to check paths for “load” files when I’m sending them to someone else.

    Wasn’t there some issue with the subst command? Granted I’ve never used it but I rember a warning about it in one of my old DOS books.

  4. There is also a freeware GUI to do this, Visual Subst, found here:


  5. Many thanks for the trick!

  6. Worth noting that the volume label is maintained from parent to virtual child, so you can’t map a folder to a drive letter and have a label which explains what it is. Rubbish.

  7. If you guys had started with DOS 3.3 like I did, you would have been using SUBST since the 1990s.

    Nothing new here, move along.

  8. just yesterday I was looking for this…but cud find any help….thanks a ton!!!

  9. Not totally sure, but I think installing to and from SUBST drives may be a bit quirky depending on the software installer.

  10. Sooo… if I where to say delete the virtual partition, would it delete the files. If I where to delete it it would be something like this (if I read the cmd help right):

    SUBST w: /D

    Is this correct, and would I delete just that virtual drive or the drive and files? Just wondering if this is equivalent to a “Hard Link”.

  11. BUT… Can we subst directory 1 for directory 2?

    I have a directory called d:\_data\archive that I want to SUBST to go to F:\backup\2004-archive

    I am using a program that has a non changable location of archive (hard coded – not in win reg), but the archive gets huge (4 Gig added every 6 mo.) so I have to break the data down and offload it to DVD’s – the program will not let me access the offline data – so to find somthing – I have to copy the data back, find the information I am looking for -then delete the data back off the perminant archive location.

    I have been looking at this problem for a few years… no luck yet…

  12. OK – now taking it one step further…

    Is there any reason why this process cannot be used to map a drive letter to a folder on a LAN….a WAN…or the biggest WAN…the internet. ?

    Instead of asigning a dive letter to a folder on your own computer or local network why cannot we use the same process to map to a folder on a remote computer through a web address so that files can be left on a server then accessed remotely from anywhere.

    If this is possible then it means that I don’t have to take a suitcase full of CD-ROMs with me everytime I travel with my notebook. I can just upload them to a folder (or two) on our web server then connect via the internet with a high sped connection.


  13. How to make a Virtual CD-ROM Drive (created with Daemon Tools or similar soft) appear inside My Documents folder, so it can be visible on a public PC, where any drive letters are not visible in Win Explorer?

  14. Hi,
    my trying to use the SUBST command-using your example-failed completely. I got no selected drive letter assigned to my folder opened constantly but the prompt window message saying INVALID NUMBER OF PARAMETERS though I hadn´t used any parameters at all! I just re-wrote exactly what you had recommended on the web page of your WXP tips. So where have I committed the fatal error? In fact, my prompt did not start with SUBST as in your sample line but with “C:\…\…\>” but that´s all the same, isn´t it?

  15. You’re right, where your prompt starts out is irrelevant to this command. I just did it from the c:\documents and settings\me directory and it was perfectly happy.

    My first thought is that you didn’t put a space between the drive letter and the path to the folder your mapping. Otherwise, I’m stumped. 1) What operating system are you using? 2) What was the exact command you wrote out?

  16. How to map a network drive to some folder. Lets say i want that network drive accessible from my WEB SERVER…..So i want to map that folder to wwwroot folder ——Please help me out urgent need!!!!!!!!

  17. sachin,

    Are you trying to map your webserver as a drive letter or a network drive through your webserver?

    I don’t know of any way to map a internet address to a drive letter.

    If you’re trying to map a network drive so that your webserver can access it that’s probably doable but you’ll have to play with the permissions on the machine. Drive letter mappings are specific to a user login. You’ll have to dig around for your specific webserver and see what it can do.

  18. Hi, thank you for you tip.
    Any tool auto startup and connect driver to my directory?

  19. i am using vista home, and i just wanted to map my movies folder in my D drive through my home network but it says cant fine the specifies location and check the spelling og the location

    i hav done all sort of cheking and troubleshooting
    help plz

  20. what if i want to substitute the following path??

    c:\new folder\test

    as you can see there is a space in folders name.
    i try subst m: c:\new folder\test
    incorrect number of parametres -folder\test

  21. manos – The trick is to use 8.3 notation. To support backwards compatibility to the ancient days dos days, Windows has a built-in short hand for names that are too long or have characters that are illegal. Though it warrants an article all by itself, here’s a short answer to your dilema:

    SUBST w: c:\newfol~1\test

    take the first six legal characters of the directory or file name, add a tilde and a number and you have the 8.3 notation for the long name.

  22. If you are trying to subst to C:\Documents and Settings\\folder or anything that has a long name and spaces, you have to make sure that you put the entire directory in quotes. So if you actually have to be:

    “C:\Documents and Settings\\folder”

  23. If you want to assign these drive settings each startup, create a batch file (filename.bat) that contains the following:

    subst g: c:\networkdrives\g
    subst n: c:\networkdrives\n

    Put this batch file in your startup folder, and it will be assigned every time you start up the computer.


    Thank you, thank you, thank you for putting this info up!!! I had a drive mapped to a folder, but round-about, though the network, which slowed it down. This helps so much!!!

  24. Now that I have a virtual drive, can I change the name of it without having to change the name of the original drive, now that would ne neat!

  25. “Be aware that when deleting any files via a virtual drive letter reference, the files are deleted immediately, bypassing the recycle been” typical windows WTF there, reminds me why unix is better

  26. You say that virtual drives are permanent until explicitly released.

  27. it is a good information about programmicially handel a folder / drive

  28. wonderful tip.
    Thanks for sharing this buddy.

Post a Comment

Your email is never published nor shared. Required fields are marked *

© 2006-2007 Maxim Software Corp.  All rights reserved.