13

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

haimg
  • 22,193
  • 16
  • 79
  • 113
iglvzx
  • 23,459
  • 13
  • 85
  • 122
  • 3
    Mounting to a folder is going to be the closest thing. – surfasb Nov 15 '11 at 00:44
  • One problem is that the `:` charachter is also used to separate the filename and the [Alternate Data Stream](http://www.symantec.com/connect/articles/windows-ntfs-alternate-data-streams) 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 Nov 15 '11 at 09:43
  • 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 Nov 16 '11 at 17:05

2 Answers2

14

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
  • 48,917
  • 12
  • 130
  • 149
  • 4
    A 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. Nov 15 '11 at 00:29
  • 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 Nov 15 '11 at 00:39
  • 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.) – u1686_grawity Nov 15 '11 at 00:43
  • @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. Nov 15 '11 at 00:49
  • 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 Nov 15 '11 at 00:56
  • @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. Nov 15 '11 at 01:04
  • @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. Nov 15 '11 at 01:05
  • @DustinG.: Technically, it does have a use, which is now a new method to mess with coworkers. . . – surfasb Nov 15 '11 at 11:01
  • @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). – u1686_grawity Nov 16 '11 at 08:18
3

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.

blong
  • 190
  • 1
  • 11
Anthony Mastrean
  • 567
  • 1
  • 6
  • 26