Using Symlinks in Windows for Fun and Profit
You may have heard of symlinks, or symbolic links, before, but weren't quite sure what they're good for. Symlinks are kind of like a wormhole in your filesystem--they're placeholders on the drive that redirect applications to whatever folder or file you point them at. They're especially handy when an application, like iTunes, doesn't allow you to configure the location it expects to find your music. So, instead of moving all your music to the folder that iTunes wants, you can simply create a symlink from the folder that iTunes expects to the folder that you prefer to store your music in. To your programs, a symlink is indistinguishable from the actual files in question.
We've found that symlinks are incredibly useful, and use them all the time. However, you can get into trouble using symlinks if you aren't careful. It's even possible to permanently damage your filesystem. The symlink is a powerful tool, and should be used carefully. When you're ready to learn, click to the next page.
  
Symlinks work best in Windows Vista and Windows 7 (OSX also includes symlinks, but we'll talk about them later). While they're lightly supported in Windows XP, they aren't quite as transparent to apps as in the later OSes, and we haven't tested them in XP, so your mileage may vary.

To create a symlink, open your command prompt--the quickest way is to press the Windows key and type cmd at the prompt--and browse to the folder you want to create a symlink in using  basic DOS commands. Once you're there, you'll use the mklink command to create your link. The basic structure of the command is mklink <arguments> <symlink> <targetoflink>. I'll break that down for you.

There are several arguments that mklink can take, but you'll probably only use two. The most useful command is the /j option, which lets you make a symlink to a directory. This will make the linked directory appear in a second location on your hard drive. You may also create a hard link to an individual file, rather than a directory by using the /h argument. The third option, /d, creates a soft link, which is more akin to a shortcut. The difference between the soft link and the hard link is that the file you hard link to appears to be stored in the link's location on the drive, while the soft linked file appears to be in its original location. If you want to symlink a directory, you must use the /j option.

In place of <symlink>, you'll need to enter the name you want for your symlink. If you're symlinking a directory, it's important that there not be a directory or file with the same name. So, if you're replacing a folder that already exists, you'll need to copy it someplace else before you can create the symlink. 

The <targetoflink> is the folder or file that you want to create the link to. You need to use the complete path to the file here, so if any of the folder names have spaces, you'll want to enclose the entire path in quotation marks.
Here are some examples:

mklink /j "c:\users\Will\Music\iTunes\iTunes Music" d:\Music\ - This line makes a symlink that redirects from the folder c:\users\Will\Music\iTunes\iTunes Music to the Music folder on my second hard drive. This type of use is especially handy if you have a small main hard drive and a larger secondary drive.

mklink /h "c:\users\Will\AppData\Roaming\AppName\settings.xml" "c:\users\Will\Dropbox\settings.xml" - This line builds a symlink between a specific settings file in your user profile directory and the same file in your Dropbox (Make sure you copy the file to your Dropbox first, or it will be overwritten!). You can use this to sync your settings across multiple computers.    
 
To delete a symlink, just browse to its location in Explorer, right click it, and press delete.
 

Beware: Danger Ahead 

There are a few things you shouldn't do, because they'll wreak havoc on your file system. There are two main rules. Don't create symlinks inside symlinks and don't create symlinks to symlinks. Doing either of these things can create loops inside the filesystem, which causes real problems for things like virus scanners.
27 Comments
kdbertel on March 18, 2010
In terms of the "don't put symlinks inside symlinks" warning, could you be a bit more descriptive?
 
For instance, is this bad?
 
I have folders c:\foo and c:\bar
I create a symlink so c:\foo\bar -> c:\bar
I also have c:\xyzzy
Is it bad if I do c:\foo\bar\blah\xyzzy -> c:\xyzzy (that is, c:\bar\blah\xyzzy -> c:\xyzzy)?
 
Or is this okay, so long as I take care to never, ever create a cycle in the filesystem?
will on March 18, 2010
@kdbertel: The problem would be if you put another symlink inside c:/bar/ to c:/foo/bar. Then you have what's essentially an infinite loop inside that folder structure. 
MarkSpivey on March 19, 2010
Will this work if linking to a WHS network drive?   
 
Mapped or not?
axphin on March 19, 2010
I've been using symlinks and junctions with windows xp and now win 7 for storing my steam savegames on my dropbox.  However I use Junction Link Magic to manage them.  It is much easier IMO.  Plus you can scan your system for existing junctions and symlinks...
 
http://www.rekenwonder.com/linkmagic.htm
natetodamax on March 20, 2010
Could someone briefly explain what these are all about? I read the article but because I'm not a genius in technology must of the terminology and what have you flew right past my head : /
Flanjygo on March 23, 2010
I like this constant stream of articles. Very nice!  However, I would like to know how to do the same thing in Linux.
 
It would be nice if you included information for Windows, Mac OSX and Linux rather than just the first two.
MarkSpivey on March 24, 2010
@natetodamax is is a way to trick any program to look somewhere other than it wants to look.  it thinks a file is located in position A, but it is really hidden in position B. 
 
Very useful if you have a small operating system drive...
Popular News
How To Rip DVDs to Play on Any Device—For Free!

Our ultimate DVD copying guide shows you how to use Handbrake to rip discs for playback on your laptop, Xbox, PS3, iPhone, Zune, netbook, iPad, PSP, iPod, and pretty much anything else

Video: How To Build the Best $1500 Gaming PC, Step-by-Step

Do you like saving money? What about playing PC games? Have you ever considered building your own PC? We show you exactly what you need to know to build an awesome $1500 gaming PC.

How To Build an Awesome $500 Windows Home Server

We pick the best parts to build a lean media backup and streaming machine.

Apple iPad Wi-Fi Review

Apple's device isn't magical, but it is going to make the tablet a real category--for better or for worse

Nexus One vs HTC Desire vs HTC Incredible: What's the Difference?

HTC is releasing more Android phones all the time, but is there a difference?

How To Steal Mac OS's Best Features for Windows

Windows 7's Aero is a fine UI, but there are just a few things it's missing. Here's how to steal some of Mac OS's features.

How To Rip a Blu-Ray Movie with Just One Click

The MakeMKV utility decrypts and rips a Blu-Ray disc with just one click, preserving the original video quality of the source file.

How To Stream All of Your Video Files to iPhone and iPad

Get your DVD rips off your computer and play them on a mobile device, without having to convert them beforehand.

You, Your Tested Account, and the New Whiskey Multi-Pass

Before the Big Live Live Show, we're adding network-wide accounts to all the Whiskey sites. Here's the scoop.

Rewatch the Big Live Live Show [Not] Live, Archived Here!

Be sure to stay to the very end.

What Kind of Digital Home Upgrades Have You Done?

Ethernet, streaming music, smart power, oh my! What 21st century upgrades have you made to your home?

Why the All-in-One Multifunction Inkjet Printer is Obsolete

Multifunction printers are big, slow machines that have lots of features, but do none of them well — and they aren't worth your time.

Why You Should Buy an iPod Classic Before it Goes Away

Last week, Apple revealed it's new line of iPods. Conspicuously absent? The iPod Classic. The high-capacity player is still around, but for how long?

Ubuntu 10.10 "Maverick Meerkat" Beta is Now Available

Itching to get your hands on Canonical's new Ubuntu 10.10 release? Here's what you need to know about the update.

Android Luring More Web Surfers While iPhone Browsing Declines

Google's Android mobile OS is gaining considerable ground on Apple's iOS, according to a recent report from Quantcast.

PAX 2010 Mini-Gallery: Cosplay is a Couples Activity

Not-so lonely geeks and geekets.

You, Your Tested Account, and the New Whiskey Multi-Pass

Before the Big Live Live Show, we're adding network-wide accounts to all the Whiskey sites. Here's the scoop.

Rewatch the Big Live Live Show [Not] Live, Archived Here!

Be sure to stay to the very end.

Free Friday - Win Norm's PAX T-Shirt Swag!

It'll be like you were at the show!

What Kind of Digital Home Upgrades Have You Done?

Ethernet, streaming music, smart power, oh my! What 21st century upgrades have you made to your home?

Why You Should Buy an iPod Classic Before it Goes Away

Last week, Apple revealed it's new line of iPods. Conspicuously absent? The iPod Classic. The high-capacity player is still around, but for how long?

Why the All-in-One Multifunction Inkjet Printer is Obsolete

Multifunction printers are big, slow machines that have lots of features, but do none of them well — and they aren't worth your time.

What are the Best Alternatives to the iPod Shuffle, Nano and Touch?

Flash-based iPod alternatives are still alive and well, contrary to what you may think, and we'll show you a few capable models on which to spend your hard earned cash.

Watch This Now: Screen Interface Technology in 2014

Your day-to-day life in the not-so-far away future.