Google Answers Logo
View Question
Q: how to create a symbolic link under Win2K, WinXP, and above? ( Answered 5 out of 5 stars,   5 Comments )
Subject: how to create a symbolic link under Win2K, WinXP, and above?
Category: Computers > Programming
Asked by: asjf-ga
List Price: $40.00
Posted: 05 May 2004 03:10 PDT
Expires: 04 Jun 2004 03:10 PDT
Question ID: 341355

 i'm under the impression that its possible to create a symbolic link
in windows similar to the unix "ln" command (ie *not* a windows
shortcut). I've been googling for a while but not come up with
anything other than windows is POSIX compliant (and WinXP isn't??) and
that you can do this under POSIX systems.

What I'm really after is the following:

1) Is it possible to create real symbolic links under windows?
2) What restrictions are there (WinXP service packs etc.., file system
must be NTFS?)
3) Is this link processable by other unix platforms (eg creating a
link under windows on a shared network drive would be an acceptable
link when viewed by another OS eg solaris/linux/hpux)
4) A snippet of C code that demos how you might do this..

thanks :)
Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
Answered By: josh_g-ga on 05 May 2004 11:42 PDT
Rated:5 out of 5 stars
Hello asfj,

NTFS 5.0 supports what they call junctions, which are similar to
symbolic links, on an NTFS filesystem.  They also allow hard links,
which are essentially the same as hard links in Unix.

A hard link creates a new directory entry for an existing file.  The
hard link must reference a file on the same volume as itself. 
Junctions, or soft links, are used to link to a directory rather than
a file.  Junctions can reference a directory on a different volume on
the same computer, but not a directory located on a shared volume from
another computer.  (See reference 1.)

While this functionality isn't very well-documented or accessible,
there is an example of this in the Computer Management MMC snap-in
(found under Administrative Tools on WinXP) under Disk Management. 
You can map a volume to a directory within an existing file structure,
rather than giving it its own volume drive letter.  This creates a
junction from the directory to the root of that volume.

Unfortunately, since junctions work only with directories, this may
not be the full functionality you're looking for.  Also, support for
junctions in Explorer is sketchy.  Deleting junction points behaves
oddly, as well as attempting to delete folders within a directory
accessed through a junction point.  (See reference 2, scroll to
"Observed Effects".)

If you still want to use junctions, you have to use an undocumented
feature of the API.  Fortunately, Mike Nordell at The Code Project had
the decency to not only figure out how to use the undocumented API
access to junction points, but explain his solution and how he came to
find it.  (See reference 3.)  You can skip straight to his solution,
implemented in VC6 on Win2000, at the following URL, but his
description of what he had to go through to figure this out is worth
reading.  (I'll leave it to you to browse there for the code, rather
than pasting it here, as it's fairly large and ugly.)

If you want to link to individual files, you're restricted to using
hard links in NTFS.  A hard link can be created using the
CreateHardLink function.  MSDN documentation for the function can be
found at:

An example usage, as seen there, looks like this:

fCreatedLink = CreateHardLink( pszNewLinkName, 
if (!fCreatedLink)
    // handle error condition

The first two parameters of the function are fairly self-explanatory
in this example.  The third parameter is "lpSecurityAttributes", which
is reserved and must be NULL when used.

I've also found some utilities for managing junctions, and have listed
URLs to them below.  You might want to use these to experiment with
how well junctions work under Windows before spending time
implementing and using them in your own code.

I could not yet find any indication whether junctions are supported or
not under various Unix / Linux implementations of NTFS.  They are a
part of the NTFS 5.0 specification, rather than a software-level
implementation like shortcuts, so a full support for the NTFS 5.0
filesystem should include them, but that's not exactly a guarantee
that such support is already available.  If you need further research
done on this point, let me know via a clarification and I will look
into it further.

I hope this answers your question!  Have a good day,
 - josh_g

Search strategies used:
windows symbolic link
junctions windows
hard link junction unix

Software utilities for using junctions:
Junction Link Magic


Other References:

2. TheFreeDictionary encyclopedia: NTFS junction point

3. The Code Project - Windows 2000 Junction Points

4. Symbolic Link On Windows

Clarification of Answer by josh_g-ga on 05 May 2004 22:18 PDT
Just to clarify, while I would expect a robust Unix / Linux
implementation of NTFS 5.0 support to be able to navigate junctions,
they still aren't Unix-like symbolic links.  So I don't think it would
follow that a Unix OS reading an NTFS 5.0 volume would allow you to
use ln -s to create junctions, for example.
asjf-ga rated this answer:5 out of 5 stars
thanks v. much :)

Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
From: cgmckeever-ga on 05 May 2004 08:41 PDT
have you tried using cygwin?  I believe it allows you making a
symbolic link AND you can remotely adminiter the file system via SSH
Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
From: asjf-ga on 05 May 2004 09:57 PDT
i've not actually tried cygwin, but i'm interested in doing this on
computers without cygwin installed - ie needing to know the Windows
API for doing this and some of the technical details behind it (see
list of questions)

thanks :)
Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
From: 8balls-ga on 18 Jun 2004 05:51 PDT
If you dont want to go into API programming, there are utilities
already compiled for that:

Symbolic links:
I've heard sysinternals has a utility for that, but couldn't find it myself.
Try finding it here:

Hard link:
Use the MS utility "fsutil". Integrated with win2000 and up.

I got all this info from this page:
Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
From: 8balls-ga on 18 Jun 2004 05:57 PDT
I have found the "juction" utility from sysinternals to create symbolic links.
They provide the source code too, so you might want to take a look at it.
Subject: Re: how to create a symbolic link under Win2K, WinXP, and above?
From: josh_g-ga on 21 Jun 2004 17:32 PDT
We must think alike when searching - I've got all of those links in
the answer above. :)

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy