Substitute a drive letter for a network or local path.

The SUBST command can be used to map a drive letter to a LOCAL folder on the same machine.

When a Substed drive is used to delete files or folders, that action will bypass the recycle bin. It will act like a network drive.

SUBST does not have any options to persist after a reboot or logoff, but you can re-initialise the substitution using a one line batch file in the Windows Startup folder or via a logon script.

If you map a drive with the NET command, use the NET command to remove it, similarly if you substitute a drive letter with SUBST then use the SUBST command to remove it.

If the network resource is unavailable (i.e. the server is down) SUBST will continually retry, unlike NET USE which will try to connect once and fail. SUBST is generally used against a local drive path where this is unlikely to be a problem.

Subst for an elevated process

If a drive is mapped or Subst'd from an elevated prompt, it will be invisible to any non-elevated process.

Error: Path not found

Subst will return a 'path not found' error if the path includes a trailing backslash. SUBST Z: C:demo\files\ ➞ will fail SUBST Z: C:demo\files ➞ will work

Undocumented behaviour

If a drive is substed using characters other than A-Z ($,#, :, !, 0-9) it will not appear in Windows Explorer or in the drives reported by SUBST. In early versions of Windows, SUBST also provided some drive mapping options that are now covered by NET USE . In early versions of Windows, SUBST would create a RECYCLER for each Substed drive.

Substitute the drive letter P: for the path D:\work files\April\ :

C:\> subst p: D:\work files\April

Remove the drive substitution from P: this does not remove any files:

C:\> subst p: /d

Map the drive letter O: to a local OneDrive for Business folder:

C:\> subst O: C:\Users\Tanisha\OneDrive

"A man should never be ashamed to own he has been in the wrong, which is saying in other words, that he is wiser today than he was yesterday" ~ Alexander Pope (thoughts on various subjects)

Related commands

NET USE - Map a drive letter to a network drive.

site logo

Assign Drive Letters to Folders in Windows

We'll show you 3 different methods to try

Author avatar

If there are folders that you access frequently, this post shows you how to quickly access these folders in Windows Explorer without having to enter the full path to the folder. We will discuss three ways to map folders to drive letters.

Method 1: Use the subst DOS Command

First, we will use an old DOS command, called subst , that allows you to assign a drive letter to any folder in Windows.

For this example, we will assign a drive letter for the following folder: C:\Users\Lori Kaufman\Documents\My Work .

Open the Start menu and enter “ cmd.exe ” (without the quotes) in the Search programs and files box. Click cmd.exe in the results to open the command prompt window.

Opening the command prompt window

In the command prompt window, type the following command to associate drive “ Y: ” with the folder.

NOTE: If there are spaces in the path name, be sure to put quotes around the full path.

Entering the subst command

Now, when we open Windows Explorer, we see a new drive labeled Y: that will directly open the My Work folder.

Drive Y: added

Use this same process to assign different drive letters to all your frequently used directories. However, the subst command cannot be used with mapped network folders.

Method 2: Use the psubst Utility

A disadvantage of using the subst command is that these virtual drives are temporary and will be removed as soon as you shutdown or restart the computer or log off. However, you can solve this by using the free psubst utility, which operates like the subst command but it creates permanent virtual drives that are persistent even after rebooting your computer.

Download the psubst utility from

https://github.com/ildar-shaimordanov/psubst

Now go ahead and read my post on how to use psubst to map a folder to a drive letter .

Method 3: Use a Graphical Tool

If you would rather use a graphical tool to map drive letters to folders, there is a free utility called, Visual Subst , that’s like a graphical version of the psubst utility.

Download Visual Subst from

http://www.ntwind.com/software/utilities/visual-subst.html

To install Visual Subst , double-click on the .exe file you downloaded.

Visual Subst executable file

On the Installation Options screen, select the check boxes for the Program Shortcuts you want to install and click Next .

Installation Options

When the setup is completed, click Close .  Double-click the shortcut to start the program. You can also start it from the Start menu.

Installation Completed

The main Visual Subst window displays. Select a desired drive letter from the drop-down list.

Selecting a drive letter

To select a folder to map to the selected drive letter, click the Browse button to the right of the edit box.

Clicking the Browse button

On the Browse For Folder dialog box, navigate to the folder you want to map, select it, and click OK .

Selecting a folder on the Browse For Folder dialog box

To map the selected folder to the selected drive letter, click the green plus button on the button bar to the left of the drive letter drop-down list.

Adding the selected=

The virtual drive is added to the list. Add more virtual drives by selecting a drive letter and a corresponding folder and adding it to the list as described above.

Virtual drive W: added in Visual Subst

If you want the virtual drives you defined available automatically when you start Windows, select the Apply virtual drives on Windows startup check box so there is a check mark in the box.

Applying virtual dries on Windows startup

To save the settings for Visual Subst , click the floppy disk button on the button bar. A file with the .ini extension is saved in the same directory where Visual Subst was installed.

Saving settings in Visual Subst

The mapped folders display as Hard Disk Drives in Windows Explorer.

Drive W: added in Explorer

If you want to remove the mapping for a folder, open Visual Subst again and select the virtual drive from the list. Click the red X button on the button bar.

Deleting a virtual drive in Visual Subst

Mapping folders to drive letters can save you a lot of time and Visual Subst makes adding virtual drives easy. Visual Subst works in Windows 2000, Windows XP, and later versions of Windows including Windows 7, 8 and 10. Enjoy!

' src=

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications. Read Aseem's Full Bio

Read More Posts:

use the command line to assign a drive letter by means of subst

Leave a Reply

Your email address will not be published. Required fields are marked *

Computer Hope

Subst command

The subst command lets you substitute a virtual drive letter for another drive letter on your computer.

Availability

Subst syntax, subst examples.

Subst is an external command that is available for the following Microsoft operating systems as subst.exe.

  • MS-DOS 3.1x and above
  • Windows 2000
  • Windows Vista

Associates a path with a drive letter.

Type SUBST with no parameters to display a list of current virtual drives.

Sets the current directory and subdirectories as the A: drive. So, if you were to type A: after executing this command, you would see everything in the directory from which the command was run.

If you reboot the computer, any subst command is cleared unless it was placed into autoexec.bat or another location that's executed upon starting the computer.

You cannot subst network drives and after a drive is created, you cannot give the new drive a new label.

How-To Geek

Map a drive letter to a folder the easy way in windows.

Have you ever needed to repeatedly access a folder that is nested deep inside a giant hierarchy of folders? Sure, you can always create a shortcut to

Have you ever needed to repeatedly access a folder that is nested deep inside a giant hierarchy of folders? Sure, you can always create a shortcut to that folder, but did you know you can actually assign a drive letter to a folder instead? Today we'll show you how to do this. This ability has existed in Windows via the subst command for quite a while, so this will also work for you XP users as well. Map a Drive Letter the Easy Way The easiest way to assign a drive letter to a folder is to use a simple utility called Visual Subst, which gives you a nice graphical interface to assign drive letters, but also does something that the command line version can't... you can set your virtual drives to apply again at startup. You can download and run the utility without needing to install it, and then simply use the Browse button to select your path, and click the green plus symbol after choosing the drive letter. At this point you should see the drive letter show up in the list. (Note that you can delete it by highlighting and choosing the red X icon, or change the path / letter by using the Save button.

image

If you want to save the drives, you'll want to select the "Apply virtual drives on Windows startup" option. Now when you open up your Computer window, you should see the new drive show up in the list.

image

The contents of the new M: drive will actually be the contents of my desktop folder. Download Visual Subst from ntwind.com Assign Drive Letters from the Command Prompt If you are more the keyboard ninja type, or just want to know how to use the command line version, you can use the subst command to map drive letters the same way by using the following syntax:

subst <driveletter> <folder path>

For example, to map the M: drive to my desktop folder I would use the following command:

subst M: c:\users\geek\desktop

If you just want to see which drive letters are assigned, you can use subst without any arguments, as shown here:

image

To delete a drive letter you can use the /D switch instead of a path... for instance, to delete the M: drive that I just created, I would use the following syntax:

subst M: /D

Now when you use the subst command to see the current drives, you'll see nothing in the list.

image

I've found the subst command to be very useful, not just in shortening folder paths but also in one instance where I wanted to delete my second partition... I just reassigned the D: drive letter to point to C: and copied all the data over. That way the application shortcuts still worked without having to reinstall the application.

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Applies To: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows Server 2003 with SP1, Windows 8

Associates a path with a drive letter. If used without parameters, subst displays the names of the virtual drives in effect.

For examples of how to use this command, see Examples .

The following commands do not work and should not be used on drives that are specified in the subst command:

The Drive1 parameter must be within the range that is specified by the lastdrive command. If not, subst displays the following error message:

Invalid parameter - drive1:

To create a virtual drive Z for the path B:\User\Betty\Forms, type:

Instead of typing the full path, you can reach this directory by typing the letter of the virtual drive followed by a colon as follows:

Additional references

Command-Line Syntax Key

Additional resources

How To Map a Local Windows Folder to a Drive Letter

Why would you want to map a folder to a drive letter? Maybe some folder you work with constantly is hidden under a convoluted folder structure, like:

'U:\Data\User Files\Shared\Clients\VIPClient\Pensky File\Project 232\'

Wouldn't it be easier to refer to it as: R:\ ?

This is pretty common to do with network locations under Tools -> Map Network Drive. However I didn't know of a way to do this with local folders until recently. You can either do it via command line or use a simple program known as Visual Subst.

(1) Using "subst" command

Under Windows, there is a legacy dos command named "subst":

C:\>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. C:\>

(2) Visual Subst

Fortunately there is an easier way to utilize this command than having to remember the command line every time you want to use your files. The free windows program Visual Subst will manage these drives for you.

VisualSubst

This program will not only allow you to create these 'Virtual Drives' but will also set them up on reboot.

From their site, download the installer if you plan on having it apply the virtual drives on startup. That way, it will install a start menu link for you and give you ready access to all virtual drives.

For anyone who works with a long folder name constantly, you will find that this really helps out when you are dealing with anything that needs to access these folders a lot!

Shane Kinsch

With AI & Robots, what can go wrong?

Create a Virtual Drive Letter for a Folder Using Subst Command

I have references on one computer that uses Google Drive mapped as a “K:” drive.  Some of the software that’s running on that computer saves it’s configuration files and details to the Google Drive area where it’s automatically sync’d to the cloud.  Since I don’t want to change all of the configs to point to a different drive letter, I’ll tell you about a secret DOS command “ subst ” which can be used to create a virtual drive in Windows Explorer for any of your desired folders.

For example, if you frequently use a folder “E:Wallpapers”, then you can create a virtual drive in Explorer which will directly go to this folder whenever you double click on it or access it from RUN or Command Prompt. It’ll save a lot of time.

Here is how to do it:

1. Open Command Prompt and provide following command:

subst drive_letter: folder_path

for example, if you want to create a virtual drive letter H: for a folder “E:Wallpapers”, then use following command:

subst H: E:Wallpapers

Creating_Virtual_Drive_using_subst_.jpg

2. It’ll immediately create a virtual drive H: which will represent the “Wallpapers” folder:

Before using subst command:

Default_Drives_in_My_Computer.jpg

After using subst command:

Virtual_Drive_in_My_Computer.jpg

3. As you can see. A new drive letter H: has been created which directly goes to “E:Wallpapers” folder upon double-click.

4. If you want to delete this virtual drive, then provide following command:

subst drive_letter: /D

for example, we created H: drive in Step1, so our command to delete this virtual drive would be:

subst H: /D

Deleting_Virtual_Drive_using_subst_.jpg

5. You can view a list of all existing virtual drives by simply giving subst command without any parameter in Command Prompt.

A. Remember! You can’t use existing drive letters for creating virtual drives, e.g. if you have 2 partitions C: and D:, then you can’t use them for subst command.

B. If your folder path contains spaces, put the whole path in double-quotes ( “” ).

C. You should not use chkdsk, diskcomp, diskcopy, format, label and recover commands on virtual drives created using subst command as these virtual drives are not real and these commands either will not work or can cause problems for the actual drives where the folders reside.

Related Posts

Easily bulk transfer domains from cloudflare via the cloudflare api, tabs outliner backup and restore, using threat feed for ad-blocking in fortios, how do i configure the default bridge (docker0) network for docker engine to a different subnet, multi-gig google fiber router & wifi mesh tri-band ports, how-to change ilan on single host ciena mcp/blueplanet install – after the fact.

use the command line to assign a drive letter by means of subst

Top Contributors in Windows 11: Ramesh Srinivasan  -  neilpzz  -  Kapil Arya MVP  -  _AW_  -  Horace Wiggins   ✅

February 14, 2024

Top Contributors in Windows 11:

Ramesh Srinivasan  -  neilpzz  -  Kapil Arya MVP  -  _AW_  -  Horace Wiggins   ✅

  • Search the community and support articles
  • Search Community member

Ask a new question

LightJack05

  • Article Author

Manually assigning a drive letter using CMD/Diskpart

[Localization from this article: Manuelles Zuweisen eines Laufwerksbuchstaben mit CMD bzw. Diskpart - Microsoft Community ]

Technical Difficulty: Expert

Applies to: Windows 10 & 11

In some cases, Windows will not assign a drive letter automatically to an inserted drive. For example, this can happen when using a Windows installation media.

In that case, you can use diskpart to manually assign a drive letter.

NOTE: If your drive doesn't get assigned a drive letter, even though you are in a normal Windows environment, this can indicate a problem with the drive. Please back up your files in that case.

Open up a command prompt (CMD/PowerShell).

Type "diskpart" to start up diskpart. You will see the prompt change to "DISKPART>".

use the command line to assign a drive letter by means of subst

Type "list vol" to list all available volumes. You can identify the drive by size and file system.

Additionally, the volume doesn't currently have a drive letter.

use the command line to assign a drive letter by means of subst

Select the volume using "sel vol <number>".

use the command line to assign a drive letter by means of subst

Assign the drive letter using "assign letter=<letter>".

use the command line to assign a drive letter by means of subst

You can now exit diskpart by typing "exit" and switch to the drive using "<letter>:".

use the command line to assign a drive letter by means of subst

It should also be available from Windows Explorer now.

50 people found this helpful

  • Subscribe to RSS feed

Was this article helpful? Yes No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this article?

Thanks for your feedback, it helps us improve the site.

Thanks for your feedback.

Comments (17) 

* Please try a lower page number.

* Please enter only numbers.

Joe13 B-) 2.0

Thanks for the tutorial, I don't think I need to use Google for it anymore!

Congrats on Article Author too! :)

Report abuse

6 people found this comment helpful

Was this comment helpful? Yes No

How satisfied are you with this comment?

Thanks for the tutorial, I don't think I need to use Google for it anymore! Congrats on Article Author too! :)

5 people found this comment helpful

Thanks! Happy I could help! :)

1 person found this comment helpful

RAJU.MSC.MATHEMATICS

Very helpful Thanks.

3 people found this comment helpful

Thank for this informative article.

I ran this in PowerShell PS C:\WINDOWS\system32> GWMI -namespace root\cimv2 -class win32_volume | FL -property DriveLetter, DeviceID

The results are below. I need to know more about the DriveLetter, that does not have a letter and I cannot give it a letter, as you can see in DiskPart.

I'm sure someone personally hacking my computer. I'm wondering if this them hiding on it, and that is why I someone is typing over me and has more control at times of my computer then I do. Maybe a hidden AD Hoc.

I have searched for this on Google I'm either getting blocked or there is no information out there on this.

PS C:\WINDOWS\system32> GWMI -namespace root\cimv2 -class win32_volume | FL -property DriveLetter, DeviceID

DriveLetter : B:

DeviceID : \\?\Volume{26xxxxxx--xxxx-xxxx-xxxxxxxxxxxxxx}\

DriveLetter : C:

DriveLetter :

DeviceID : \\?\Volume{d5xxxxxx--xxxx-xxxx-xxxxxxxxxxxxxx}\

DriveLetter : D:

PS C:\WINDOWS\system32> DiskPart

Microsoft DiskPart version 10.0.19041.1

Copyright (C) Microsoft Corporation.

On computer: My Computer

DISKPART> List Volume

Volume ### Ltr Label Fs Type Size Status Info

---------- --- --- -------- ----- ---------- ------- --------- --------

Volume 0 D RAW DVD-ROM 2048 B Healthy

Volume 1 B System Rese NTFS Partition 100 MB Healthy System

Volume 2 C NTFS Partition 698 GB Healthy Boot

2 people found this comment helpful

I followed the instructions to CHANGE the letters assigned for three external hard drives. (The computer had named them E, F, G but gave the names to the wrong external hard drive) I changed the letters to the correct names singly (I disconnected the two not being adjusted) Now, I have 2 E, 2 F, 2 G names in the list (when accessed through File Explorer. When I click on "This PC", it shows just the one of each. If I click on either, or both of the same letter name, the same exact files will open. This is annoying. Anyone have a clue what can be done? This is on a brand new computer running Windows 11.

Sorry about the late reply.

That sounds weird... Usually, windows doesn't allow you to assign a drive letter twice.

If you want to change the letters, you usually have to remove them first and then reassign them.

Can you send me a screenshot of disk management, and of the list of volumes?

the partition that is not shown in diskpart is most likely some sort of recovery or reserved partition.

This is not the typical way of hiding an infection with malware...

Also, do note that your ESP (Volume B) should not be mounted, since modifying it can corrupt your Bootloader.

As for the suspected hacking, what symptoms did you observe? Mouse moving on its own, high resource usage, unexpected firewall prompts? Other things?

If you have a compromised system, its almost impossible to clean it from infections without doing a clean install of windows. I would suggest you do that if you suspect an infection. It will take time though and will delete everything on your PC. (Including files, programs, settings.) Create a backup before you reinstall.

There are no viruses nor malware on this computer. I believe it is a reflection of the original name choice. The information contained on each external hard drive is identical, yet when I go into MY PC, it only shows one set of externals. I am afraid to delete one of the duplicates because it might be just mirrored and it will make everything go away. I have way too many things on these external hard drives to lose any of them.

Thanks for your input. Jan

Forum Article Info

  • Devices and drivers
  • Norsk Bokmål
  • Ελληνικά
  • Русский
  • עברית
  • العربية
  • ไทย
  • 한국어
  • 中文(简体)
  • 中文(繁體)
  • 日本語

Mapping folder as a virtual drive letter using subst

It can be useful to map a very deep nested folder as a drive letter, so it is easier to access by Windows Explorer along with all other applications. The command line utility subst.exe provides this functionality:

Subst x: C:\Very\Long\Folder\Path

To free the assigned drive-letter again use the subst command like this:

Subst x: /D

Note when restarting the computer then all mapped drive letters are forgotten. One can put the subst command into a startup-script which is launched at startup , so the mapping is done automatically again at user login.

Note the utility Visual Subst is a more GUI friendly utility for managing virtual drives created with subst (Has option to mount drives at boot / startup).

Note Windows Vista User Account Protection introduces a special behavior with Subst.exe as the drive-letter is only seen by the user-account that has performed the mapping. This means that when changing between regular user and elevated user then, one has to perform the subst command in both contexts.

Credits SearchWinComputing.com

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How do you map a virtual drive letter to a local path on Windows?

All in the title. I'm looking for how to reference a local, not network, path, as a virtual drive letter. An innocuous example: C:\Storage as G:

Sam Cogan's user avatar

  • 2 Deleting from the lettered drive seems to have the annoying side effect of bypassing the recycle bin. :( –  Christopher Galpin Apr 13, 2010 at 10:25

2 Answers 2

I recently researched this subject and these are my findings.

The subst command performs this function well, and its effect ends with the user session:

vSubst by Thomas Bigler is a GUI for subst, it can also create a permanent association by running itself at startup (HKLM), just as subst could be configured to do.

For a permanent mapping this may not be preferable as anything loaded prior won't be able to reference the mapping, for instance entries added beforehand alongside it in HKLM -> [...] -> Run, Windows services, etc.

psubst on Google Code is an excellent batch script with the interface of subst (which it uses internally) with an additional optional /p parameter for managing permanent mappings through the following key, which is loaded much earlier:

You can also map to your local drive as if it were a remote one with

It does bind late in the login process though.

matt wilkie's user avatar

  • I don't think I knew that. Clever. –  Christopher Galpin Sep 27, 2011 at 21:18

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged windows ..

  • The Overflow Blog
  • Optimizing both hardware and software for GenAI sponsored post
  • Defining socially responsible AI: How we select partners
  • Featured on Meta
  • Changing how community leadership works on Stack Exchange: a proposal and...
  • Our partnership with Google and commitment to socially responsible AI

Hot Network Questions

  • Expected value of the square root of a lognormal variable
  • how to display a distance matrix in latex
  • Is there an email address equivalent of “/dev/null?”
  • Is it a tetrate of two?
  • Can you finish a quality steak in the microwave
  • Advice for investing money for a 15-year old
  • How does pitch bending work on keyboard percussion
  • Latex3: Passing empty token list to another command and detecting it as empty token list
  • shrinkwrap or surface deform for clothing poking through other clothing?
  • What happens if a slow train hits you?
  • Fppf or étale extension of group algebraic spaces
  • Why do people in Central Asia view Russia in a positive light?
  • Predatory journal threatens me to either pay or they will retract the paper visibly online
  • Function templates for serializing/deserializing POD types
  • Why is Nikki Haley referred to as "Ambassador"?
  • Alternative Representation for Energy Levels and Energy Level Density (II)
  • Why is net favorability for Israel so high in Nigeria even after the Gaza incursions?
  • Can a smooth curve have a segment of straight line?
  • Is 4th interval found at 3rd overtone?
  • How to choose reverse polarity protection - diode vs MOSFET
  • Which European countries have laws that closely resemble the Russian law against discrediting the armed forces?
  • Making a dynamic table
  • Are there general solutions to quadratic, 2D, continuous, time-invariant dynamical systems?
  • Can a community charitable organization collect donations on behalf of a specific person?

use the command line to assign a drive letter by means of subst

use the command line to assign a drive letter by means of subst

How to map a folder to a drive letter on Windows

Overcome the windows path length limit, fix issues with linked files and avoid long browsing times by mapping a commonly used folder to a drive letter..

use the command line to assign a drive letter by means of subst

Whether you reached the path length limit on Windows by having a deep folder structure or you work in a team using Dropbox and everyone has their Dropbox folder in a different place, you can map the drive letter. This will show up next to all drives and look like an actual hard drive.

Maped folders to drive letters

Useful utilities for your workflow

Method 1: windows cmd.

When you don’t want to rely on other software and when you are not afraid of writing commands, you can use the Windows command prompt (CMD).

  • Press the Windows Key
  • Type CMD and press Enter

use the command line to assign a drive letter by means of subst

  • Type “subst” and press space
  • Type your drive letter and a “:” e.g. Z: and press space again
  • Drag the folder into the command prompt which you want to map as a drive

use the command line to assign a drive letter by means of subst

  • Press Enter

use the command line to assign a drive letter by means of subst

Remove the drive

You can also remove that drive by typing the following CMD command. “subst” your drive letter “:” “/D” e.g.

The “/D” deletes the mapped drive. It only removes the mapping and does not touch the folder.

Method 2: Anchorpoint

If you don’t want to mess with the command line, then Anchorpoint is a suitable solution for you. Anchorpoint is a collaborative file browser that is bundled with a lot of productivity utilities.

  • Download Anchorpoint, create an account and launch the application
  • Open “Workspace Settings”

Workspace settings in Anchorpoint

Under “Actions”, enable “Map Folder as Drive”

Action settings in Anchorpoint. They allow to map folders to drive letters

  • Browse to your folder
  • Right click and choose “Map as Drive”

Map as Drive mounts a folder as a drive letter

Pick your drive letter and press “Map”

  • Do a right click anywhere in the browser and choose “Unmap Drive”
  • Pick your mapped drive and press “Unmap”

Anchorpoint uses the Windows API, so the effect is exactly the same. Drives are still being mapped when restarting the computer.

Related articles

use the command line to assign a drive letter by means of subst

How to properly reorganize your Unreal Engine project structure

Learn how to manage assets and how to reorganize files and folders in Unreal Engine. Handle file paths, fix redirectors, and reorganize projects efficiently. Use version control to revert back to the working state when something breaks.

use the command line to assign a drive letter by means of subst

Anchorpoint at Zazu

Learn how Zazu, a global creative union, streamlines their motion design projects for clients like LinkedIn and FIFA using Anchorpoint for asset management.

use the command line to assign a drive letter by means of subst

Anchorpoint at Hertha Produziert

How Hertha Produziert uses Anchorpoint to organize their files and produce first-class explainer videos, commercials and any kind of motion content.

Anchorpoint logo

  • Documentation
  • Unreal Engine Source Control
  • Unity Version Control
  • 3D Asset Management
  • To Perforce
  • To GitHub Desktop
  • To Plastic SCM
  • Privacy Policy
  • Mobile Computing

use the command line to assign a drive letter by means of subst

  • Good to know
  • VPN for streaming
  • VPNs for gaming
  • Privacy news
  • VPN reviews
  • Windows 11 News
  • Windows 11 Help
  • Windows tips
  • Windows Update
  • Data Recovery
  • File Sharing
  • Microsoft Office
  • Firefox add-ons
  • Chrome Extensions
  • Internet Explorer
  • Microsoft Edge
  • Google Maps
  • Google Android
  • Thunderbird
  • Crypto & Blockchain
  • Development
  • Music and Video

Assign Drive Letters to Folders

subst virtual drives folders

Did you know that it is possible to assign drive letters to folders so that you can access those folders as if they were hard drive partitions?

This makes it not only easier to access those folders on the system, as you do not need to navigate to them first in Windows Explorer, but also makes running programs easier especially from the command line as you do not have to enter the full path to the folder but the abbreviated one instead. In addition, it may speed up load and save operations on Windows systems.

It is very easy to assign a drive letter to a folder, to do that, do the following:

  • Click Start, select run and enter cmd. You can alternatively bring up the run box with Ctrl-r, typing cmd and hitting enter.
  • This should open the command line interface of your windows operating system.
  • The command that we need is the "subst" command and we use it the following way: subst drive folder . Make sure you don't add a trailing slash to the folder as the path may not be found otherwise by the command.
  • Lets say you want to assign the drive letter X to the folder d:\movies on your hard drive. To do that you write the following command: subst x: d:\movies

That is all. Fairly easy isn't it? Now the drive letter x: remains accessible as long as you do not turn off or reboot windows.

subst virtual drives folders

If you want to make this permanent you will have to do the following:

  • Create a new file and name it drive.bat. Edit the file and add the line subst x: d:\movies to it and save it.
  • Right click the Start button, select Open All Users.
  • Open Programs, Startup and right click that location.
  • Select New Shortcut, and select the drive.bat file that you created.
  • Select Next and finish.
  • The command will be executed for all users during every startup of windows so that the folders can be accessed using the selected drive letter.
  • If you are running Windows 95 you can edit the autoexec.bat and add the line there.

Update : If you do not like to work with the command line or bat files, you could head over to NTwind to download Visual Subst instead, which is a gui version of the program.

visual subst

To use the program simply select a drive letter in its interface and pick a folder from a hard drive to link the two together.

Assign Drive Letters to Folders

Related content

Next Windows

Microsoft showing Windows 11 upgrade prompts on more Windows 10 devices

Windows

The latest Windows 11 Security Update fails to install for some users

Windows 11

Windows 11 version 24H2 may block devices without SSE 4.2 support

use the command line to assign a drive letter by means of subst

Windows 11 version 23H2 is going to be installed automatically on older systems

Windows Copilot

Windows 11: Copilot is gaining more Windows management options (with a catch)

Windows

Windows 11's final "Moment Update" has these new features

Tutorials & tips.

use the command line to assign a drive letter by means of subst

How to Capture Screenshots on Windows 10 and 11

use the command line to assign a drive letter by means of subst

Quick Ways to Open Device Manager in Windows 11

use the command line to assign a drive letter by means of subst

Here is How to Permanently Disable Windows Defender

use the command line to assign a drive letter by means of subst

4 Tested Ways to Install Windows 11 on Unsupported CPU

The command works in Window 7 but cannot get the Batch file to run at start up.

very nice :)

Leave a Reply Cancel reply

Save my name, email, and website in this browser for the next time I comment.

Advertisement

Spread the word, hot discussions.

use the command line to assign a drive letter by means of subst

Recently Updated

use the command line to assign a drive letter by means of subst

Latest from Softonic

  • More companies join forces against AI: OpenAI and Microsoft on the ropes due to copyright
  • About to finish ‘GTA 6’, Rockstar makes a decision about its employees for pure safety
  • The video game that lost its Twitter account due to Elon Musk’s silliest mistake
  • Creating fuel on satellites in space? The US is testing it

About gHacks

Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.

  • Legal Information
  • Terms of use
  • Privacy Policy
  • Cookie Policy
  • Cookie settings
  • Advertise with Us
  • Martin Brinkmann
  • Mike Turcotte

use the command line to assign a drive letter by means of subst

Share with Your Friends

How to map OneDrive to a drive letter in Windows 11

Your email has been sent

Image of Mark W. Kaelin

Over the past few years, TechRepublic has published several articles showing you tricks and tips that allow you to designate a specific drive letter to Microsoft OneDrive . This was necessary because Microsoft no longer allows it using conventional methods. Well now, a reader has informed us that with the update to Windows 11 , one of those tricks has become obsolete. So, we must find another way.

Once upon a time, long before Windows and graphical user interfaces, personal computers were run from the command line using DOS. Many of those ancient legacy commands are still viable, even in Windows 11. This is where we will find the commands we need to designate a specific drive letter to Microsoft OneDrive.

SEE: 3 must-have calculator tools for the tech professional (TechRepublic Premium)

Before we begin, some of you may be wondering why you would want to give OneDrive a drive letter in the first place. I learned a long time ago that when it comes to how people use their PCs, it is best to go with the flow and assume there is a good reason.

In this case, a reader asked for help after discovering that a previous tip no longer worked . So, we are helping to solve the problem the best we can. That said, what if you were writing a script in PowerShell that referenced OneDrive? Using a drive letter as shorthand for a specific OneDrive folder could come in handy.

SEE: How to roll back Windows 11 and return to Windows 10 (TechRepublic)

The first thing we need to do is start our command-line session with administrative rights. In Windows 11, click the search icon in the taskbar and type “cmd” into the search box. Select Run as Administrator from the options list to reach the command line window shown in Figure A .

use the command line to assign a drive letter by means of subst

To accomplish our task, we will be using the “subst” command, which is short for substitute. Its simple function is to substitute a drive letter for a specific folder recognizable by the operating system. The basic syntax looks like:

The most difficult part of this trick is determining exactly what path your installation of Microsoft OneDrive uses according to the operating system. To do that, we must take advantage of some DOS-level directory surfing.

First type “cd/” and then type “dir”. These are the DOS change directory and the display directory commands respectively, and we are changing our focus to the root directory ( Figure B ) and getting a list of subdirectories on the main drive (most likely C:).

use the command line to assign a drive letter by means of subst

The OneDrive directory is a subdirectory of a subdirectory of the Users directory, so we type “cd/Users” at the command prompt and then request another list of subdirectories by typing “dir” again, as shown in Figure C .

use the command line to assign a drive letter by means of subst

Now, this is where it gets interesting. For my PC, the user directory is named “mark” but for your PC it will be completely different. Whatever the name, the next command should be “cd/Users/(fill in your directory name)”. For our example, the commands would be:

Your results will be similar to the screen shown in Figure D . Note, you must type in the full path for the command to work. A DOS limitation.

use the command line to assign a drive letter by means of subst

In our example, the name of my OneDrive directory is called “OneDrive – Mark W Kaelin”. As you can imagine, referencing that in a script could be a nightmare. We can substitute a single drive letter (Z:) for that long string of directory names using this command:

Note the use of the quotation marks. We must surround our directory path in quotation marks because it contains spaces. DOS considers spaces to be a break, which means it expects the next bit of text to be a new command. Another DOS limitation. Of course, your OneDrive directory name will different from mine.

If you now, type “z:” into the command prompt and type “dir” you will see your Microsoft OneDrive listed in all of its DOS glory ( Figure E ).

use the command line to assign a drive letter by means of subst

Close out the command-line session and then load Windows File Explorer. When you scroll down the left-hand list of folders, you will find Z: on the list of available drives, as shown in Figure F .

use the command line to assign a drive letter by means of subst

Unfortunately, this setting is not permanent. The next time your PC is restarted, this substitution will be lost and will have to be reapplied. If you want to permanently designate a drive letter to Microsoft OneDrive even during a restart, you will have to resort to another ancient technique known as the autoexec batch file, which is some deep DOS voodoo requiring its own separate article.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

  • Microsoft OneDrive: A cheat sheet
  • How to use OneDrive with Microsoft 365 desktop
  • How to search for apps, files and other items in Windows 11
  • How to become a software engineer: A cheat sheet
  • Cheat sheet: Windows 10 (free PDF)
  • Hiring kit: iOS developer
  • Must-read coverage: Programming languages and developer career resources

Image of Mark W. Kaelin

Create a TechRepublic Account

Get the web's best business technology news, tutorials, reviews, trends, and analysis—in your inbox. Let's start with the basics.

* - indicates required fields

Sign in to TechRepublic

Lost your password? Request a new password

Reset Password

Please enter your email adress. You will receive an email message with instructions on how to reset your password.

Check your email for a password reset link. If you didn't receive an email don't forgot to check your spam folder, otherwise contact support .

Welcome. Tell us a little bit about you.

This will help us provide you with customized content.

Want to receive more TechRepublic news?

You're all set.

Thanks for signing up! Keep an eye out for a confirmation email from our team. To ensure any newsletters you subscribed to hit your inbox, make sure to add [email protected] to your contacts list.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Can a single volume be assigned multiple drive letters?

I am working on migrating data across many disparate drives onto one massive Windows 8 Storage Space.

Problem I have is that many of my programs reference various drive letters to acces their libraries, files, music, movies, etc.

Is there any way I can, for example, have any reference of drives D, E, F, and G all point to the new drive S:?

Jared Tritsch's user avatar

2 Answers 2

Yes, use the subst command in the command line: subst NewLetter: OldLetter:\

For example, to assign the current C: drive the letter H: as well: subst H: C:\

See subst /? for more info.

Bob's user avatar

  • 1 Awesome, I was going to suggest mklink , but this works just fine. –  Caleb Jares Oct 28, 2012 at 7:18
  • @cable729 That would not be possible. Directory junctions and symlinks are NTFS features, so you cannot assign a drive label as a link. –  Bob Oct 28, 2012 at 7:22
  • I successfully created a link from C:\d to D:\ –  Caleb Jares Oct 28, 2012 at 7:22
  • @cable729 But you cannot link C: (the label) to D: . You linked a folder to a drive, not a drive label to a drive. Also, this requires an NTFS partition mounted as C: to put the link on , which defeats the purpose of consolidating drives as in the question (since the whole point is to reduce the number of partitions/combine data on one partition). –  Bob Oct 28, 2012 at 7:25

You can't run subst as admin, but as a regular user instead, or your "new" drive won't be recognized. Once I ran the "regular" command prompt it worked.

Reference: Windows Explorer not recognizing subst'd drives

random's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged hard-drive windows-8 ..

  • The Overflow Blog
  • Optimizing both hardware and software for GenAI sponsored post
  • Defining socially responsible AI: How we select partners
  • Featured on Meta
  • Changing how community leadership works on Stack Exchange: a proposal and...
  • Our partnership with Google and commitment to socially responsible AI

Hot Network Questions

  • build_runner showing error The getter 'macroKeyword' isn't defined for the class 'ClassDeclaration'
  • Why did the Tessier-Ashpool family create two separate AIs?
  • Display image title and caption on posts and pages
  • Which European countries have laws that closely resemble the Russian law against discrediting the armed forces?
  • What's a pithy term to describe what a spy does when he/she socializes with a target to get information?
  • Can a community charitable organization collect donations on behalf of a specific person?
  • Interpreting generating functional as sum of all diagrams
  • Sending the rookie shopping
  • How does pitch bending work on keyboard percussion
  • How do we know that common rearrangement proofs of the Pythagorean theorem work for any right triangle?
  • Could Occam's Razor ever favor theism?
  • A word for a man of few, but well thought-out, words
  • SF short story about a man trapped in torus with triangular cross-section
  • What's the background to the popularity of turquoise in Russian architecture?
  • What are toy examples of single-copy entanglement conversion?
  • Catching exceptions and rolling back transactions
  • Would vechile insurance be valid if someone else other than person, whose name the insurance is under, drives it?
  • Losing time due to my boss being consistently late
  • Exploring Elastic Constants Calculation in VASP: Methods and Best Practices
  • How to choose reverse polarity protection - diode vs MOSFET
  • What happens if a slow train hits you?
  • Solution of SDE at finite time, continuity of pdf
  • Why is Nikki Haley referred to as "Ambassador"?
  • Is materialism essential to scientific progress?

use the command line to assign a drive letter by means of subst

IMAGES

  1. Assign Drive Letters to Folders in Windows

    use the command line to assign a drive letter by means of subst

  2. How to assign permanent letters to drives on Windows 10

    use the command line to assign a drive letter by means of subst

  3. 3 Simple Ways to Assign a Drive Letter in Windows 10/8/7

    use the command line to assign a drive letter by means of subst

  4. How to Assign and Remove Drive Letter with Diskpart in Windows 10 or 11?

    use the command line to assign a drive letter by means of subst

  5. Change and Assign Drive Letter in Windows 10

    use the command line to assign a drive letter by means of subst

  6. Assign Drive Letters to your Frequently Used Folders in Windows

    use the command line to assign a drive letter by means of subst

VIDEO

  1. How to Change Drive Letter in Windows 11/10

  2. MetaEditor lesson #3

  3. Name a folder a driver letter

  4. sata hard drive boots incompatible fix. non raid fix

  5. How to Manually Assigning a Drive Letter Using CMD / Diskpart in Windows 11/10 [Solved] #diskpart

  6. How to format and/or assign drive letters using Disk Management in Windows 7

COMMENTS

  1. subst

    Specifies the virtual drive to which you want to assign a path. [<drive2>:]<path> Specifies the physical drive and path that you want to assign to a virtual drive. /d: Deletes a substituted (virtual) drive. /? Displays help at the command prompt.

  2. Subst

    SUBST does not have any options to persist after a reboot or logoff, but you can re-initialise the substitution using a one line batch file in the Windows Startup folder or via a logon script. If you map a drive with the NET command, use the NET command to remove it, similarly if you substitute a drive letter with SUBST then use the SUBST ...

  3. Assign Drive Letters to Folders in Windows

    Method 1: Use the subst DOS Command. Method 2: Use the psubst Utility. Method 3: Use a Graphical Tool. For this example, we will assign a drive letter for the following folder: C:\Users\Lori Kaufman\Documents\My Work. Open the Start menu and enter " cmd.exe " (without the quotes) in the Search programs and files box.

  4. Subst Command

    Subst command information for MS-DOS and the Windows command line. Page includes subst command availability, syntax, and examples. ... Associates a path with a drive letter. SUBST [drive1: [drive2:]path] SUBST drive1: /D. drive1: Specifies a virtual drive you want to assign a path. [drive2:]path: Specifies a physical drive and path you want to ...

  5. Map a Drive Letter to a Folder the Easy Way in Windows

    Download Visual Subst from ntwind.comAssign Drive Letters from the Command Prompt If you are more the keyboard ninja type, or just want to know how to use the command line version, you can use the subst command to map drive letters the same way by using the following syntax: subst <driveletter> <folder path> For example, to map the M: drive to ...

  6. windows 7

    The best way is through drive management. You can specify a path to mount a drive to rather than a drive letter. Go to Control Panel -> Admin Tools -> Computer Managment -> Drive Management. Right click on the volume you want to change, and select Change Drive Letter and Paths.

  7. How to Map Local Folder as Drive with letter in Windows 11

    Create a folder you want to map. Right-click on it and select the Copy as path option. Right-click on the Start Menu. Select Windows Terminal (Admin) option. Click on the Yes button in the UAC ...

  8. Subst

    To create a virtual drive Z for the path B:\User\Betty\Forms, type: subst z: b:\user\betty\forms Instead of typing the full path, you can reach this directory by typing the letter of the virtual drive followed by a colon as follows: z: Additional references. Command-Line Syntax Key

  9. Command to assign local folders as network drives with drive letters

    Assign a drive letter to the local folder! With the command: 1. show connected: subst. 2. remove connected from z: subst /D Z: 3. connect C:\Windows: subst z: c:\windows\system32. we can assign the Z:\ drive to the folder and access it! PS: When you restart the computer, any Subst command will be deleted unless it was placed in autoexec.bat or ...

  10. How To Map a Local Windows Folder to a Drive Letter

    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. C:\>.

  11. Resolve Windows drive letter to a path (subst and network)

    I wonder if there is a universal way of resolving a path using a drive letter (such as X:\foo\bar.txt) into its equivalent UNC path, which might be one of the following:. X:\foo\bar.txt if X: is a real drive (i.e. hard disk, USB stick, etc.) \\server\share\foo\bar.txt if X: is a network drive mounted on \\server\share; C:\xyz\foo\bar.txt if X: is the result of a SUBST command mapping X: to C:\xyz

  12. Create a Virtual Drive Letter for a Folder Using Subst Command

    After using subst command: 3. As you can see. A new drive letter H: has been created which directly goes to "E:Wallpapers" folder upon double-click. 4. If you want to delete this virtual drive, then provide following command: subst drive_letter: /D. for example, we created H: drive in Step1, so our command to delete this virtual drive would ...

  13. Manually assigning a drive letter using CMD/Diskpart

    Open up a command prompt (CMD/PowerShell). Type "diskpart" to start up diskpart. You will see the prompt change to "DISKPART>". Type "list vol" to list all available volumes. You can identify the drive by size and file system. Additionally, the volume doesn't currently have a drive letter. Select the volume using "sel vol <number>".

  14. Mapping folder as a virtual drive letter using subst

    The command line utility subst.exe provides this functionality: Subst x: C:\Very\Long\Folder\Path. To free the assigned drive-letter again use the subst command like this: Subst x: /D. ... This means that when changing between regular user and elevated user then, one has to perform the subst command in both contexts. ...

  15. How do you map a virtual drive letter to a local path on Windows?

    The subst command performs this function well, and its effect ends with the user session:. subst [drive1: [drive2:]Path] vSubst by Thomas Bigler is a GUI for subst, it can also create a permanent association by running itself at startup (HKLM), just as subst could be configured to do.. For a permanent mapping this may not be preferable as anything loaded prior won't be able to reference the ...

  16. How to map a folder to a drive letter on Windows

    Use the Command Prompt from the Start menu. Type "subst" and press space. Type your drive letter and a ":" e.g. Z: and press space again. Drag the folder into the command prompt which you want to map as a drive. Your prompt should look like this. Press Enter. Your drive should appear in the devices and drives section.

  17. Assign Drive Letters to Folders

    It is very easy to assign a drive letter to a folder, to do that, do the following: Click Start, select run and enter cmd. You can alternatively bring up the run box with Ctrl-r, typing cmd and hitting enter. This should open the command line interface of your windows operating system. The command that we need is the "subst" command and we use ...

  18. DOS Command: SUBST

    DOS Command: SUBST. SUBST. Type: External (3.1 and later) Syntax: SUBST d: d:path SUBST d: /D Purpose: Substitutes a virtual drive letter for a path designation. Discussion Use the SUBST command to substitute a drive letter for a path in order to treat a virtual drive (a reserved area rather than an actual disk drive) as a physical drive. In ...

  19. How to map OneDrive to a drive letter in Windows 11

    The first thing we need to do is start our command-line session with administrative rights. In Windows 11, click the search icon in the taskbar and type "cmd" into the search box. Select Run ...

  20. Can a single volume be assigned multiple drive letters?

    Yes, use the subst command in the command line: subst NewLetter: OldLetter:\. For example, to assign the current C: drive the letter H: as well: subst H: C:\. See subst /? for more info. Associates a path with a drive letter. drive1: Specifies a virtual drive to which you want to assign a path.

  21. windows

    find the first unused drive letter; create a new drive with subst ; do something on this drive ; remove the drive with subst ; ... Or maybe there is an alternative to the subst command? I tried using a powershell drive, but it doesn't work with other windows programs (e.g. devenv.exe). ... Can a judge assign a murder victim's paid counsel to ...