How to map a local folder to a drive letter in Windows

Mock network environments and map hidden paths for easy access

Have you ever wanted to create a drive letter mapping within your local system under Windows? Usually the mappings are reserved for network paths, but it can be useful for development (or even just as a shortcut) to map a local path to a drive letter.

Mapping network paths to drive letters has been a familiar task in corporate life. You’ve got your report server to access, accounting has their own NAS, there is a backup server, and so on. These handy shortcuts keep you from having to navigate down a long tree of folders to reach commonly used resources, wherever they are on your network. On windows, you can get the same functionality for local resources as well.

1_23.jpg

To map a path to a drive letter, you can use either the subst or net use commands from a Windows command line. The main difference between the two is that subst expects the location to always be available. If for some reason that location can’t be found, it will try desperately to reconnect at the expense of your computers performance. net use on the other hand is more fault tolerant. When a mapped path appears to be disconnected, it will gracefully disable that mapping until you try to access it again, at which point it will attempt to connect again. More detail can be found on stackexchange.

Map a drive with subst

To create a new mapping:

subst x: C:\Folder\Example

To remove a mapping:

subst x: /D

Map a drive with net use

net use x: \\localhost\c$\Folder\Example

Why is this useful you might ask? For me it’s useful when I need to mimic a client’s environment that I don’t have access to during development. If I know a resource is going to be on the W: drive, I can create a W: drive and map it to a local folder. It’s also useful for hard to access file system locations, such as the hidden AppData directory.

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon