Symbolic links (symlinks) in Windows 7 or Vista

2011 January 14

One feature that was notoriously absent from Windows until recently was the ability to create symbolic links. A symbolic link is merely a small piece of code that is put in some physical location (DIR1) which tells the operating system to move somewhere else (DIR2) when software attempts to access DIR1. I use this feature regularly in OS X or other Linux distributions, mainly as a way to sync files through Dropbox without having to messily move where my software stores my files, although I also like shortening the absolute path to various directories that look like they were named by a scientist having too much fun with alphabet magnets on the fridge.

In Unix speak, this is quite easy– open up a terminal window and type:


This has finally been added in Windows Vista and Windows 7, but remains somewhat sloppy and confusing. Here is a very brief reference for those trying to do a similar thing in Windows, with emphasis on the flags.

mklink \PATHTO\DIR1\file.txt \PATHTO\DIR2\file.txt

You will be returned with:

symbolic link created for \PATHTO\DIR1\file.txt <<===>> /PATHTO\DIR2\file.txt

This is the most basic entry for creating a symlink between files. The one issues? This creates a soft link (essentially the same as creating a shortcut in Windows Explorer). If I am doing something like syncing my Keepass database, I will actually break this symlink because the software will not be forwarded to the file on a basic level– it will merely sit in the folder and go “where the hell is my database?” and either create a blank one or give some other error message.

To solve this problem we need to use the /H flag which tells Windows to create a hard link. A hard link physically points to the secondary location. You’ll want to use this option if you are trying to trick an application into looking for a different directory. For me, most of the time.

mklink /H \PATHTO\DIR1\file.txt \PATHTO\DIR2\file.txt

Now that’s how to symlink files– you need additional flags for directories. /D tells Windows that you are creating directory links, not file links. If you only use /D you will create a soft link. /J instructs the OS to create a “junction” which is (functionally) the equivalent of the hard links discussed above. In most cases I find myself using /D and /J before the link and target.

mklink /D /J \PATHTO\DIR1\ \PATHTO\DIR2\

Also remember, if you type “mklnk” at the command prompt, you will be returned with basic instructions for using the functions described above:

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.

Hopefully the above helps demystify the procedure a bit, however. read more to learn ways to improve your website’s rank on the internet.

Find this page useful? Save you a few dollars fixing something?
If you so desire, feel free to kick back a dollar or two to help site upkeep.

8 Responses leave one →
  1. 2014 July 17

    I see a lot of interesting posts on your blog.
    You have to spend a lot of time writing, i know how to save you a lot of work, there is
    a tool that creates unique, SEO friendly articles in couple of seconds, just type in google – k2 unlimited content

  2. 2014 July 27

    My family always say that I am wasting my time here at net, however I
    know I am getting knowledge all the time by reading thes fastidious content.

  3. 2015 January 7

    Awesome posts you post here, i have shared this post on my twitter

  4. 2015 January 7

    Hi, after reading this remarkable piece of writing i am too glad to share my
    familiarity here with colleagues.

  5. 2015 January 8

    I have been exploring for a little for any high-quality articles or blog posts on this
    sort of house . Exploring in Yahoo I finally stumbled upon this
    web site. Studying this info So i am satisfied to express that I’ve an incredibly excellent uncanny feeling I discovered exactly what I needed.
    I such a lot unquestionably will make certain to do not omit this website and give it a
    look regularly.

  6. 2015 June 8

    A� Our inner beings never see weakness or negative things.
    You have probably heard of the great Law of Attraction before and how you attract into your life, people,
    circumstances and situations in proportion to the thoughts you entertain within your mind.
    This will result in you actually initiating and instigating a form
    of self- healing that you can connect with anytime you choose to do so.

  7. 2015 July 22

    Hello, I believe your web site could be having browser compatibility problems.
    When I look at your web site in Safari, it looks fine
    however, when opening in IE, it’s got some overlapping issues.

    I merely wanted to give you a quick heads up! Other than that, fantastic site!

  8. 2018 March 6

    After that, aall you have to ddo is to wait for day when you cann
    view your favorite NFL team. We found out that the Intex Seahawk 400 wass tough to
    maneuver if you have lots of wind. Pros – One fro
    the nice aspects with the Intex Seahawk 400 inflatable
    boat is everything that iis needed to accwss it the river
    quickly is included.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS