Is it possible to mount a volume to a custom drive prefix, e.g. "myDrive:\"?

13

3

Am I just a dreamer, or does something like this exist?

iglvzx

Posted 2011-11-15T00:10:02.353

Reputation: 21 611

3Mounting to a folder is going to be the closest thing. – surfasb – 2011-11-15T00:44:11.223

One problem is that the : charachter is also used to separate the filename and the Alternate Data Stream name. MyDrive:Foo names the Foo stream in the MyDrive file, not the Foo file in the Current Working Directory of the MyDrive disk. Also, why do you want to do this?

– MSalters – 2011-11-15T09:43:21.223

I figured that it may be easier with static shortcuts and such. For example, if I have a link to E:\etc, it is only useful if E: is still the same volume. I suppose a better solution would be to mount the volume to Z: or other never-used letters. – iglvzx – 2011-11-16T17:05:03.960

Answers

13

No, you cannot. It is called a drive letter for a reason.

The command myDrive: gives the error

'myDrive:' is not recognized as an internal or external command, operable program or batch file.

Note that is does not have to be a letter in the traditional sense. You can call your drive [:, for example.

DOS allowed you to use all ASCII characters between A and ` (both inclusive), giving you a total of 32 different drive letters. I am not sure how to access the last 6 on Windows though.

The closest you can get to your "dream" is mounting. For example, you can mount a drive (a partition, actually) in the folder C:\myDrive.

Another "solution" that will work for the Windows Explorer is adding an expandable string value to the registry key

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders.

This is where the actual locations of Desktop, My Music and such are stored.

Dennis

Posted 2011-11-15T00:10:02.353

Reputation: 42 934

4A drive letter does have to be A-Z, you cannot have a non alpha character. As you said "It is called a drive letter for a reason" – Dustin G. – 2011-11-15T00:29:03.327

1@DustinG.: I do not know about recent versions of Windows, but those that still had a config.sys can have drive letter that are not letters. All you need is 2 optical drives and specifying Z as the first drive letter for them. This is how I wound up with [: a couple of times... – Dennis – 2011-11-15T00:39:17.530

1@DustinG: Technically, DefineDosDevice() in Windows NT accepts anything in the 0x1..0xFF range. In practice, though, very few programs accept "/:" or "[:". (You can even define foo: that way, but it just won't work.) – user1686 – 2011-11-15T00:43:20.613

@Dennis that seems to be a fluke with 3.1 or 9x, I would like to test that but there is no facility for directly or indirectly (as you propose) to give a drive a non alpha assignment on NT systems. – Dustin G. – 2011-11-15T00:49:34.330

2@DustinG.: I googled it and the 32 drive letters seem to be a special case of Windows 95, 98 and (possibly) Me. However, there is still a method that will work on Windows 7: Try subst [: C:\. Now you have drive letter [. – Dennis – 2011-11-15T00:56:41.707

@Dennis using the subst command, you are just creating a virtual drive "letter" so now the C drive takes both C: and [: and does help the OP with what they want. – Dustin G. – 2011-11-15T01:04:27.520

@Dennis I do stand corrected on using a non alpha character to refer to a drive but it's limited and fairly useless – Dustin G. – 2011-11-15T01:05:10.703

@DustinG.: Technically, it does have a use, which is now a new method to mess with coworkers. . . – surfasb – 2011-11-15T11:01:39.200

@Dustin: It is, however, possible to create a subst-like mapping directly to the volume name (the \\?\Volume{...} path) without the need for an alphabetic drive letter assignment, by using the aforementioned DefineDosDevice() (which, by the way, is what subst itself uses). – user1686 – 2011-11-16T08:18:04.057

2

You can create custom named "drives" using the PowerShell provider system. You would do something like

PS> New-PSDrive -name myDrive -PSProvider FileSystem -Root "F:"

You would then access the files/directories under that same drive like

PS> dir myDrive:\whatever\foo

It wasn't clear from your question if you were in a scripted/console environment or if you wanted to see this in Windows Explorer specifically. Also, I assume you were talking about a filesystem "volume". The PowerShell provider system also supports other kinds of providers.

Anthony Mastrean

Posted 2011-11-15T00:10:02.353

Reputation: 525