Home > Batch programming, Windows > Associate a path with a drive letter

Associate a path with a drive letter

Use SUBST command…

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. An e.g. usage, create a  “p:” virtual drive for documents and settings folder path…

subst p: "C:\Documents and Settings"

To delete an existing virtual drive use…

subst /D p:

To see all existing virtual drives created…

C:\Documents and Settings>subst
N:\: => C:\
P:\: => C:\Documents and Settings

Also note that on machine restart these drives are not restored, for restoration after startup, create a batch file and put it into “Startup” folder in explorer. After a virtual drive is created, explorer shows this as an independent drive.

Advertisements
  1. Sarath
    March 18, 2009 at 7:35 am

    Thanks Nibu this is really helpful.

  2. K. Ed
    March 17, 2009 at 1:21 pm

    Interestingly, you can subst a non-letter drive (e.g. 1: ), it won’t be displayed anywhere, but you can go to such drive by typing 1: .
    Some programs might get crazy when operating with files on such drive.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: