The SUBST command in Windows CMD allows you to map a path to a drive letter, creating a virtual drive that appears in File Explorer and all command-line interfaces. This is primarily useful for simplifying file paths and making deep directories more accessible. It is often used in environments where specific paths need frequent access or when legacy applications require a particular drive letter.


The basic syntax for the SUBST command is as follows:

SUBST [drive1: [drive2:]path]
SUBST drive1: /D
  • drive1: The drive letter you want to assign to the path.
  • path: The local path you want to assign to the drive1.
  • /D: Deletes a previously created virtual drive.

Detailed Syntax

  • To map a directory to a drive letter:
    SUBST drive1: path
  • To remove the virtual drive:
    SUBST drive1: /D


  • /D: Removes a mapped virtual drive. Use this flag only if you need to delete an existing mapping.


  1. Creating a Virtual Drive
    Map the C:\Users\Username\Documents directory to drive Z::

    SUBST Z: C:\Users\Username\Documents

    After this command, you can access C:\Users\Username\Documents by simply going to the Z: drive.

  2. Deleting a Virtual Drive
    To remove the virtual drive Z::

    SUBST Z: /D

    This command eliminates the mapping, reverting any access to Z: to its state prior to the mapping.

Common Issues

  • Permission Issues: Ensure you have sufficient permissions to the directory you intend to map. Lack of permissions can prevent the mapping.
  • Drive Letter Already In Use: Attempting to substitute a drive letter that is already in use can result in an error. Make sure the drive letter is free before attempting to assign it.
  • Persistent Across Reboots: SUBST mappings are not persistent across reboots by default. You will need to remap or add the command to a startup script.


SUBST can be effectively combined with batch files to automate setup tasks or prepare an environment. For example, you can create a batch file that maps multiple directories to different drive letters for a development environment.

@echo off
SUBST X: C:\Path\To\Project
SUBST Y: C:\Path\To\Tools
echo Drive letters assigned for project and tools.
  • NET USE: For network drives mapping, rather than local folders.
  • PUSHD/POPD: Temporarily changes the current directory.

For more detailed information about SUBST and related commands, you can refer to the official Microsoft Documentation: Microsoft’s SUBST command page.