Wednesday 22 March 2017

Add logical subst drives permanently to Windows

A Windows program expected to see a D: and an O: drive and the program was running on a virtual machine.

My first thought was to get the system admin to create 2 virtual drives on my VM machine but then I remembered from my MSDOS days the "subst" command.

Subst associates a path with a drive letter.

I had a problem that the subst command wouldn't associate drive d: because the virtual CDROM was assigned to that drive.

My first task was to disable the CDROM on the virtual machine. For that I used the device manager and just disabled the CDROM.

Drive D: was now able to be allocated into a logical drive.

I created two directories on C: drive:
d_drive
o_drive
I then created the two logical drive using the "subst" DOS shell command. In a command shell I issued the commands:

subst d: c:\d_drive
subst o: c:\o_drive

I now had two logical drives but when I restarted the VM the 2 logical drives are gone.

Thanks to google I found a way to make that permanent. I created a logical.reg file and gave it the following contents:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\Control\Session Manager\DOS Devices]
"D:"="\\??\\C:\\d_drive"
"O:"="\\??\\C:\\o_drive"
 I then ran:
regedit logical.reg
 The two logical drives were now installed

1 comment:

  1. Or you could create a batch file to run at start up to do it. Your method is neater though. I'll change mine to a registry one since without the old autoexec.bat I had to create a task to automatically run at startup which paints an ugly dos box on the screen.

    ReplyDelete