Monday, September 28, 2009

Links and Junctions in Windows (yes, even in XP)

link –s

A command that hearkens to the goodness of Linux…
Windows can do that, too!

My wife recently created a directory for scanned documents on her system under the "My Documents" folder.

I wanted this new folder that my sweetie named, "My Paperless Lifestyle", to automatically upload/sync to her Dropbox account.  This would allow me to access the files on any computer with Dropbox installed.

I looked at the preferences for Dropbox on her machine, and Dropbox only syncs files that are stored under the
"c:\Documents and Settings\debbie\My Documents\My Dropbox"
folder in my wife’s profile.

Debbie’s machine is running Windows XP, so I grabbed the JUNCTION.EXE utility from Microsoft (thank you, Mark Russinovich!) to make a "fake" folder (junction, or symbolic link) under Dropbox that would point to the scans.  A machine running Vista or higher would use the command MKLINK instead.  Now the scans can be accessed on any computer with Dropbox installed.  I can then access the stuff Deb scans on my work computer or laptop, and the added bonus is I don’t have to mess up my wife’s existing folder/organizational structure.

Here’s the command:

C:\> junction -s "c:\Documents and Settings\debbie\My Documents\My Dropbox\scans" "C:\Documents and Settings\debbie\My Documents\My Paperless Lifestyle"   


Now let’s open the Dropbox folder, and…


There it is, an NTFS junction point called scans, that actually refers to the

"C:\Documents and Settings\debbie\My Documents\My Paperless Lifestyle" folder.

If a directory listing is output it looks like this:


<JUNCTION> doesn’t really tell us the secret location of where scans really points, so instead of using DIR, here’s the JUNCTION command with scans as a parameter.

That’s it!  Now you can fool programs into thinking files are in one place, when the files are actually stored in your preferred location.

I’ve used this same technique to have multiple users on the same machine use the same Firefox profile.  This helps prevent me from installing the same Add-ons for Firefox for each one of my children individually.  I like reducing redundancy and the machine is configured so that only one user can be logged on at a time(it’s a netbook).

Maximum PC has a great article with examples on using MKLINK in Vista, Windows 7, etc.  Here is another post explaining the differences between symbolic links and hard links(junctions are the directory version of hard links) in a Windows context.

1 comment:

William J. Familia said...

This is a nice feature. I am sure I have serveral applications I could be using it on to simplify life.