Using SUBST to Create Virtual Drives in Windows

A deeply nested project path is tedious to type and awkward in scripts that expect a short root. subst maps that folder to a drive letter, so D:\Projects\Client\2026\Build\Output becomes P:.

The command has been in Windows since DOS. It creates a virtual drive that points at a local folder, visible to Explorer and to any application that opens a path.

What Is SUBST?

SUBST stands for “substitute”, and it lets you assign a drive letter to a local path.
It doesn’t move or duplicate anything — it just maps a folder as if it were a separate drive.

You know that 100-character-long C:\Users\Zaur\Projects\SuperImportant\StuffToDemo path?
You can turn it into Z:\ in one line.

Basic Syntax

SUBST <DriveLetter>: <FolderPath>

Example:

SUBST Z: "C:\scripts"
SUBST creating a virtual drive letter in the Command Prompt

Now you can access Z:\ in Explorer, Command Prompt, or any app — and it will point to that long path.

How to Remove a SUBST Drive

SUBST Z: /D

The drive disappears. No files deleted. Nothing moved. It’s like it never happened.

See All Current Mappings

SUBST

This lists all current virtual drives created with SUBST.

SUBST run without parameters, listing the current virtual drive mappings

Why Use It?

Common Use Cases:

  • Shorten long, deep file paths for easier navigation
  • Simplify dev environments (e.g. set W:\ for your web root)
  • Help legacy apps that expect to run from a drive root
  • Create throwaway drives for testing installs, scripts, or tools

Caveats to Know

  • Mappings made with SUBST do not persist after reboot unless added via script or registry
  • SUBST drives behave like local drives in Explorer, but some software (especially older ones) might not fully support them
  • Doesn’t work with network shares — only local paths

Pro Tip: Make It Persistent

To keep your SUBST drive alive after reboot:

Option 1: Add it to a startup script (Task Scheduler or Startup folder)

SUBST Z: "C:\Path\To\Folder"

Option 2: Use the Registry (manual but reliable)

Add under:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

Add a new String Value:

  • Name: Z:
  • Data: \??\C:\Path\To\Folder
Registry Editor showing the String Value that recreates the SUBST drive at logon

Note: The \??\ prefix is important — it tells Windows this is a symbolic path.

To Remove the Mapping

  • Go back to the same registry key
  • Delete the string value (e.g. Z:)
  • Reboot

Extra Notes

ThingDetail
Drives created this wayShow up like real drives
Still point to foldersNo duplication — just a redirected path
Affects all usersSince it’s under HKLM
Requires admin rightsYes — it’s editing system-wide settings

Summary

CommandWhat it does
SUBST Z: C:\FolderMaps folder to a virtual drive
SUBSTLists all current mappings
SUBST Z: /DDeletes the mapping
Registry + DOS DevicesMakes the mapping persistent on reboot

Final Thoughts

SUBST might not be flashy, but it’s a lightweight tool that can seriously declutter your daily workflow. Whether you’re coding, scripting, or just sick of typing long paths, it’s a shortcut worth remembering.

Got a favorite SUBST trick or using it in your workflow? Drop a comment — or stay tuned for a post on net use and mapping network drives the smart way.


Related guides