Vista Gets It: Symlinks at Last!

OK, we take our last post back, Vista does have several exciting features to blog home about (and guys, for the last time, that comment’s what they call sarcasm!) one of which is the much requested “Symlinks” feature. It’s been in practically every other operating system for the past decade+ and is one of the most essential time-saving devices ever to be implemented. For those of you (Windows-dwelling creatures) that don’t know what a symlink is yet, here’s the Wikipedia definition.

Symlinks save tons of space by making files “pretend” to exist where they don’t, but even more importantly is the time they save by allowing you to create/reference a static filepath in all your programs – then have that “file” redirect to the real deal, no matter how often it changes. If you’re a web-dev kinda guy, think of it as mod_rewrite for your hard drive, without the PCRE libraries though… (come to think of it, the first OS to implement regex into symlinks has my vote!)

On Linux/BSD/Unix it’s called ln:

CG@neosmart [~]# ln --help
Usage: ln [OPTION]... TARGET [LINK_NAME]
  or:  ln [OPTION]... TARGET... DIRECTORY
  or:  ln [OPTION]... --target-directory=DIRECTORY TARGET...

but if you’re reading this, you probably already knew that; or at the very least you know where you can find the man page.

On Windows, it’s a very similar procedure. Microsoft had long promised that symlinks would ship with Vista, and every build we’ve been enthusiastically entering the ln command and hoping to get something other than the dreaded

'ln' is not recognized as an internal or external command, operable program or batch file.

But it turns out that it’s been in there for a while — just hiding under a different name. It’s called mklink (in keeping with the mkdir nomenclature obviously), and it works just as well.

C:\Users\Computer Guru.NEOSMART>mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

Now all Microsoft needs is to implement a mod_rewrite (or use one of the existing open-source implementations?) into IIS7 to suddenly kick-up the competition a notch…

Hat Tip: Thanks to Kristan Kenney!

  • Similar Posts

    Craving more? Here are some posts a vector similarity search turns up as being relevant or similar from our catalog you might also enjoy.
    1. Vista Symlinks Revisited…
    2. Open Source, 100% Compatible ln for Windows (and Junction Point library)
    3. Using Bad Word Filters to Boost SEO & Productivity
    4. What Windows Live™ Needs to Make it Work
    5. Internet Explorer 7 RC1 Review & Open Search
  • 11 thoughts on “Vista Gets It: Symlinks at Last!

    1. Windows has actually had this ability since 2000, at least for directories. In Windows nomenclature, they are called junctions, and can be created using either the linkd tool from the resource kit, or junction.exe from SysInternals…

      I admit, it might be nice to finally be able to symlink files though

    2. Hey Cynic..

      Actually, that’s a common misconception. “Junctions” in Windows 2000+ are actually hard links, and not symlinks as many people suppose.

      There’s a fairly large gap between the two, and hard links offer few to none of the advantages of real symlinks. But Windows XP does have add-on (3rd party freeware) that adds Symlinks to the Kernel, but it’s not really reliable in my experience.

      *OK, I can’t for the life of me find that freeware link that I saw while writing this article, but I’ll post back if/when I do.

      Here’s the Wikipedia link on Symlinks and Hardlinks – a bit hard to spot the difference at first, but it’s there.

    3. I know only Windows and I have to work on this tedious Solaris operating system for last 3 days. Can anybody tell me how to verify if a file/folder/service is systemlinked to /usr/local/bin? Say the binary “abc” is copied in /usr/local/xyz after installing a package and nowI need to know if “abc” is symlinked to /usr/local/bin or not. Please provide clear instructions like I am used to see in Windows Support manuals. It will be great, if you can mail me at krish3765@yahoo.com.

    4. Hi,

      Tedious solaris? Solaris is very good OS. Ok here you go. One thing is that you can search for all symlinks in the system and just grep for the /usr/local/bin or whatever you want. You can do all this in couple of unix commands.

      find / -type l -exec ls -l {}\; >/tmp/all-sym-links-in-system

      Now open the file to find what you are looking for.

      Prem.

    5. Ohh.. sorry.. mistyped the command

       

      find / -type l -exec ls -l {}\; >/tmp/all-sym-links-in-system

    6. Hi
      I am not able to run a file after I created it by the mklink command.
      Please refer to the steps below
      1) i created a applocation file using

      C:\>mklink foo notepad.exe
      symbolic link created for foo <> notepad.exe

      2)Then I tried to start the application using
      C:\>start foo
      At this point the system asked me to choose a program from the list of programs to run the file foo.

      3)Next I tried to create the link using the following command

      C:\>mklink foo.exe notepad.exe
      symbolic link created for foo.exe <> notepad.exe

      And then wen I gave Start foo.exe, I got the error message :
      C:\>start foo.exe
      The system cannot find the file C:\foo.exe.

    7. Is there any UI equivalent of creating symlinks with Vista – preferably via Explorer (e.g., right click drag a file to another explorer folder location)?

    8. “come to think of it, the first OS to implement regex into symlinks has my vote!”

      Oh Yes!
      – mine too!

      Once i write an Operating System, based on php and Javascript! 😉

    Leave a Reply

    Your email address will not be published. Required fields are marked *