Windows: Symbolic Links and Virtual Drives

A few years back, I was working in a development shop using a source control package that insisted that all of the developers using it have their code in the same logical location. We settled on "D:\Code" for our standard and made sure everyone stuck too it, as changing the setting to anything else screwed up the rest of the team. This worked fine for the first 5 or so developers, but when the new PCs came it, they had large "C" drives, and no "D" drives. Most of the old timers did not have the space on their C drives to move the code there, so we had a bit of a conundrum. How did we get everyone to put their code in the same place if they physically couldn't?

One of our local techs mentioned a nifty built-in CLI command called "SUBST", which could be used to assign a drive letter to local path. So, in our case, we took all the PCs with only C: drives and mapped "C:\Code" to "D:" with

subst D: C:\Code\

Now, the new PCs had a "D:\" in their File Managers, even though they had only one drive. In this arrangement, "C:\Code\Code" and "D:\Code" were aliases for the same files.

To make it persist across reboots, we clumsily created a "startup.bat" file and launched it from the startup folder. Now days, you can do it more cleanly with a registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices
Name:  "D:"
value: "\??\C:\code"

But what if you want to go the other way? What if you need to point a directory to a different drive letter?

About a year ago, I bought a PC with a 60GB hard drive. I knew it wasn't a particularly large hard drive, but I had tons of network space and figured it wouldn't really matter. And 64K is all the memory anyone will ever need.

Not long after I got the PC, I became enamored with a game called Oblivion. Aside from nice game play, a good story, and some some cool graphics, the game was practically infinitely moddable. Before my first character had cleared the tutorial, I was already adding nifty new mods. It was at least as much fun as the game itself, adding sharper textures, more logical rules, and cool new items. In no time flat, I'd blown my 60 GB and couldn't even launch the game. What to do?

Because the game ran on my C drive, my infinite network space was worthless. I had to buy a new hard drive, which I did immediately. But the game was installed on C. I suppose I could have deleted it and reinstalled it on my new D drive, but that would obliterate my save games, and untold hours modding the game to perfection I had achieved. It was fun to mod a game, but less so to RE-mod it.

The first thing I did was reset all my "My *" folders. These are the "My Documents", "My Pictures", "My Games", etc. created by the operating system. You can right-click these bad boys, go to "Properties", and adjust them to "Set Save Location" to wherever you want to. It even moves the current contents to the new location for you. Unfortunately, I don't use these folders a lot and got about a gig out of the effort. It was time for Plan B.

After some searching, I came across an app called "Junction", originally developed by a company called "SysInternals" and since bought out by Microsoft. What this app did was create a "Symbolic Link" between one physical location and another. So, I took the "C:\Program Files\Oblivion\Data" folder, which contained all the mods I'd downloaded, and pointed it to the D drive:

D:\>md GameFiles
D:\> CD GameFiles
D:\GameFiles\>md Oblivion
D:\GameFiles\> CD Oblivion
D:\GameFiles\Oblivion\>md Data
junction D:\GameFiles\Oblivion\Data "C:\Program Files\Oblivion\Data"

I had to move the files myself, but it worked like a charm and, in fact, was even persistent across boots. Now, a directory that had been using 40 GB of my available 60 GB was suddenly sitting on my new 500 GB drive. I should note that this app doesn't support remote shares (hence the new local hard drive).

So I suppose the moral of our story is that, at least in the metaphysical world of computing, "location" is little more than a logical construct. With the right tools and little know how, things are "located" where you say they are. Sadly, my keys and cell phone don't inhabit that world.