Ever since I started developing using Unix machines I've wanted symbolic links in Windows XP. A recent pursuit of backup solutions left me really wanting symbolic links so I started the search. This blog post gave me everything I needed, using a tool from Microsoft's website called junction.
This command line tool created junction points between a symbolic name and a real folder on your hard drive (sorry network drives cannot be linked to).
I downloaded it and placed the
junction.exe file in my
C:\WINDOWS\system32 directory so it would be on my system path.
Below is my little walk-through of how to use junction.
I created a folder on my desktop called "junction test" and created a folder inside that called "folder":
I created a text file called "README.txt" inside the "folder" directory:
I opened a Windows DOS prompt (cmd) and navigated to the "junction test" folder on my desktop, then I ran the junction command like this:
junction "junction" folder
This gave the following output:
Junction v1.05 - Windows junction creator and reparse point viewer Copyright (C) 2000-2007 Mark Russinovich Systems Internals - http://www.sysinternals.com Created: C:\Documents and Settings\abeacock\Desktop\junction test\junction Targetted at: C:\Documents and Settings\abeacock\Desktop\junction test\folder
And the folder now looked like this:
If I double-clicked on the "junction" folder this is what I saw:
So as you can see the contents of the "folder" directory is now available in via the "junction" directory as well. Obviously the junction doesn't need to be next to the folder you want to link too (that would be of little use) but it can be anywhere on your harddrive (I was using it to point into my DropBox sync folder).
Only the junction tool knows that these folders are actually symbolic links, the rest of the Windows file system thinks they are normal folders. So for example you can simply delete the junctions via Windows and they go in your recycle bin and the folder that it points to stays where it was:
So please remember to always use the junction command to create & delete junctions, you can also use it to show you which directories are actually junctions so you know if you should delete it or not, refer to the junction download page for more details.
It's a fantastic tool for Windows XP and very very handy for certain things but please bear in mind the warning above...
Technorati Tags: Symbolic Link, Junction, Microsoft, Andrew Beacock