Mapping drive letters to local folders
Is there a windows equivalent to the old dos SUBST command?
I want to be able to assign a local drive letter to a folder on a local drive.
I realize that a mapped drive will work (and so far that's the technique I've ended up using), but it doesn't seem to cut-in until rather late in the boot process. I've also in the past tried putting SUBST commands in batch files in the boot process, but that doesn't seem to work either.
6 Answers
Good news! The subst command still works in Windows 7!
To create a new mapping:
subst x: C:\Folder\Example
To remove a mapping:
subst x: /D
Alternative:
net use x: \\localhost\c$\Folder\Example
The difference between net use & subst below break
subst
When a share becomes unavailable subst will try over and over again to re-connect severely impacting performance of your PC as it tries to re-connect. This is less common when mapping local files as it will only occur if you say re-name the folders in the path. The resolution if this does occur is subst x: /d
net use
net use was introduced in win2k/xp to provide an alternative to this. When net use is used to connect to a location and that location becomes unreachable windows will report drive as disconnected and not try to re-connect until user tries to re-connect to resources on the mapped drive. This resolves the performance issues noted in subst
For more information on both commands you can query via the command line with /?
net use /? & subst /?
The best way to do this across bootup is to put it in the registry. Open regedit.exe and navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS DevicesAdd a new REG_SZ value and name it X:, where X is your drive letter
The value should be the path in this form
\DosDevices\C:\Folder\Example 5 Another way is to put a share on the folder you want to map. You can then use the map network drive option which can be accessed by right clicking on my computer in windows explorer.
Note you will need to turn on network discovery before setting up the share.
The advantage of this approach is you set the option of create on logon.
Just to add to the answers above. Another option is a symbolic link which is covered in this SU question How to mount a network drive to a folder?
1The best way is through drive management. You can specify a path to mount a drive to rather than a drive letter.
Go to Control Panel -> Admin Tools -> Computer Managment -> Drive Management.
Right click on the volume you want to change, and select Change Drive Letter and Paths.
This way, you can remove the original drive letter all together, and have it mounted under a directory only. This is how you can get around the 24 drive limit in windows.
2