Wednesday, November 6, 2013

Create a Virtual Drive through a Command Prompt

Just a few weeks back, I was working on a very old application where in all the directory paths used in the code were hard coded and pointing to a S:/ drive.

Since I did not have a drive "S" on my machine, and I had to make the application up and running, I was left two choices:
1. Rename all the directory paths in the application, OR
2. Create a Virtual Drive

Option 1 seemed to be a lot time consuming and hence I chose option 2 which I felt was a lot easier to do.

I searched on the net, and found out one command which could be used to create virtual drives.

Windows OS has an application called "subst" which helps in creating virtual drives mapped to the local folder.

The syntax of the command is:
SUBST [drive1: [drive2:]path]

subst S: C:\Dev

When you run this command, a drive will be created with a letter S: assigned to a local folder "Dev" on drive C. 

This is an easy way to create Virtual Drives, though the drives will be deleted/removed when machine is rebooted. You will have to create the drives again.

I have developed a small tool to create Virtual Drives. Download here.

No comments:

Post a Comment