symbolic links

Tool Tip: Junction for Windows XP

During my years at university I spent majority of my time on a command line, working on unix systems. One of the things I loved about unix was the ability to create symbolic links.

A symbolic link allows you to ghost the location of a file or folder to another location on your file system. This means that you can create a symbolic link from a folder (e.g. /myproject/tools/nant ) which points to another folder on the file system (e.g. /common/tools/nant/). The main benefit of doing this means that you can link to a common file or folder from many projects and maintain just one copy of that file or folder. Reducing duplication is what the DRY principle is all about, so you know its good.

Now that I’m mainly using Windows as my development OS, I don’t have symbolic links anymore. Vista has them under a different name but that won’t help anyone using Windows XP. That’s where Junction comes in handy.

Junction - A symbolic link tool for Windows

After downloading junction, I placed the executable file into C:WINDOWSSystem32 so that it will be available from the command line (i.e. it will exist in the “path” environment variable). The next step is to now create a junction!

Give this a try:

C:>junction.exe c:Test c:WINDOWS

After completing, you should be able to see the following:

C:>dir
 
 Directory of C:
 
11/11/2008  23:32                 0 AUTOEXEC.BAT
11/11/2008  23:32                 0 CONFIG.SYS
15/01/2009  06:31    <DIR>          Documents and Settings
11/11/2008  23:36    <DIR>          Intel
10/03/2009  15:39    <DIR>          Program Files
11/11/2008  23:43               173 Setup.log
11/03/2009  13:53    <JUNCTION>     Test
09/03/2009  13:44    <DIR>          WINDOWS
               3 File(s)            173 bytes
               5 Dir(s)  136,112,881,664 bytes free

Notice that Windows recognises the new folder as a Junction, not a Directory. Now have a look inside C:Test

C:>dir Test
 
 Directory of C:Test
 
09/03/2009  13:44              .
09/03/2009  13:44              ..
09/03/2009  13:44                 0 0.log
11/11/2008  15:18    <DIR>          addins
19/06/2008  23:20            57,344 ALCMTR.EXE
19/06/2008  23:42         2,808,832 ALCWZRD.EXE
11/11/2008  15:22    <DIR>          AppPatch
14/04/2008  12:00             1,272 Blue Lace 16.bmp
14/04/2008  12:00            82,944 clock.avi
11/11/2008  23:28               200 cmsetacl.log
14/04/2008  12:00            17,062 Coffee Bean.bmp
15/01/2009  06:35             1,444 COM+.log
.
.
.

What you should see is all the files contained inside C:WINDOWS. This means that C:Test now points to C:WINDOWS and appears to contain all the same files.

Removing a Junction is simple:

C:>junction.exe -d c:Test

A WORD OF WARNING: If you delete a file in the Junction folder, it will delete the real file. Be careful not to delete files inside a Junction thinking that it will only affect that Junction.

And that about sums up the simple side of Junctions! I find it really useful to link to a common tools folder in each of my projects, so that I can get to the easily from the project and only store them on disk once. Hopefully you can find a good use for them in your next project.

Share this article:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogosphere News
  • Fleck
  • LinkedIn
  • Live
  • Netvibes
  • Print this article!
  • StumbleUpon
  • Technorati
  • Tumblr
  • TwitThis
  • Yahoo! Buzz
  • BlinkList
  • blogmarks
  • De.lirio.us
  • DZone
  • feedmelinks
  • Furl
  • IndianPad
  • kick.ie
  • LinkaGoGo
  • Linkter
  • MisterWong
  • MySpace
  • Netvouz
  • NewsVine
  • Ping.fm
  • Reddit
  • scuttle
  • Slashdot
  • Socialogs
  • SphereIt
  • Spurl
  • Taggly
  • Webnews.de
  • Wists
  • YahooMyWeb

Tags: , , , , ,

Wednesday, March 11th, 2009 Tool Tips 1 Comment