DEV Community

iainrough
iainrough

Posted on

Map a Local Folder to a Virtual Drive - Windows 10

The Problem

I ran into a licencing issue with an old ASP.NET Web Forms project. The developer license links to the initial install location. Due to the age of the project, I can no longer update the licence key for the new location.

    d:\projects\{client}\src 
The path linked to the license.

So how do I create a location on a drive that my current machine does not have?

Option 1: Make a new partition on my machine (Not ideal)

Option 2: Google a different solution.

Found the following article from 2014: How to map a local folder to a drive letter in Windows. It looked simple to implement and not a permanent change.

The SUBST command

   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.
The subst help output.

1. So first things first I needed a root folder to map to.

 mkdir c:\files\fakeddrive 
The fake root folder

2. Next up duplicate the folder structure:

 
    mkdir c:\files\fakeddrive\projects
    mkdir c:\files\fakeddrive\projects\{client}
    mkdir c:\files\fakeddrive\projects\{client}\src
 
Create the path

3. Next up run subst

 
   subst d: c:\files\fakeddrive
 
Run The Command

The results

   > subst
   D:\: => C:\files\fakeddrive
List of current virtual drives.

image


There are a couple of things to keep in mind:

  • Don't run as an elevated user.
  • The drive does not survive a reboot.
  • remove the mapping subst d: /D

Top comments (0)