120

Windows Vista added the ability to create symbolic links to files and directories. How do I create a symbolic link and what are the current consumer and server versions of Windows that support it?

3
  • 6
    Can someone highlight the differences between a symbolic link and a shortcut?
    – tomjedrz
    May 12, 2009 at 2:46
  • 1
    @tomjedrz: if you are using shortcut, any APIs to open that shortcut will open a text file that contains the path to the target file/folder. if you are using links, any APIs to open that link will open the target file/folder. Feb 17, 2012 at 3:55
  • 2
    Contrary to what all people have said, I confirm that it is possible to use symbolic links in Windows XP. (I use it to install Picasa database on VM shared folder). Just take a look at schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html and navigate to section "Symbolic links for Windows XP". HTH Oct 24, 2012 at 6:48

8 Answers 8

115

You can create a symbolic link with the command line utility mklink.

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.

Symbolic links via mklink are available since Windows Vista and Windows Server 2008. On Windows XP and Windows Server 2003 you can use

fsutil hardlink create <destination filename> <source filename>

According to msdn.microsoft, Symbolic Links are NOT supported on FAT16/32 and exFAT. It seems Windows only supports them from or to NTFS-Partitions. Future Windows operating systems are likely to continue support for mklink.

You can read further information about this new feature on Microsoft TechNet, Junfeng Zhang's blog or howtogeek.com.

8
  • Would be nice to add David's Technet url to your entry for completeness. May 11, 2009 at 18:22
  • site note, what is a juntion (/J option) ?
    – Roy Rico
    Sep 22, 2009 at 21:06
  • A Directory Junction a type of directory symbolic link. support.microsoft.com/?kbid=205524 Dec 7, 2009 at 8:09
  • 1
    NTFS has been supporting links (with various names) since Windows 2000, but they were only used internally, most notably in the SYSVOL domain shares; some utilities were available for managing them, but were not built-in; Vista introduced the MKLINK tool and the extensive usage of links on default Windows installations.
    – Massimo
    May 9, 2011 at 14:13
  • 2
    Would be nice to mention fsutil from @sascha's answer below to provide a solution for Windows Server 2003.
    – Phrogz
    Jul 19, 2011 at 22:13
30

On Windows XP you can use fsutil (built into the OS) to create a hardlink

 fsutil hardlink create c:\foo.txt c:\bar.txt

Keep in mind fsutil will only work if both are on same drive

2
  • 2
    Good answer. I'm on WinXP / Win2003 and needed mklink, but this solved my issue for me. I usually use junction.exe from sysinternals, but that only handles directories and in this case I needed a file link
    – s3v1
    Mar 16, 2011 at 10:37
  • A pity a symbolic link cannot be created by fsutil, at least from what I've read elsewhere. This is a hard link and thus not an answer to the question.
    – Vlasec
    May 5, 2015 at 12:01
10

One small thing, if you are using Powershell, mklink does not work directly, run it like this:

PS C:\d\eclipseInstalls> cmd /k mklink /D antRunner 3.4.2
symbolic link created for antRunner <<===>> 3.4.2
1
  • 1
    That should be /c, not /k, otherwise cmd.exe won't exit.
    – dangph
    Mar 15, 2010 at 7:04
7

Use mklink or junction from Sysinternals (Microsoft). I believe mklink will work in Windows 2000 and above, but I cannot find any hard documentation on that. junction is for Windows 2000 and above.

1
  • 1
    The command mklink is Vista and Server 2008 and up only, as I pointed out above.
    – user1797
    May 11, 2009 at 18:12
4

Didn't see this in any of the answers, but linkd.exe (in the Windows 2003 Resource kit here) allows you to create junctions, which pretty much function as a soft/hard link does in Linux. Junctions are available from Windows 2000 and up, so just copy linkd.exe to the target system and it should work.

1
  • 1
    Note that ` /linkd` is only for directories, not files.
    – Phrogz
    Jul 19, 2011 at 22:11
3

If you are still on old Windows, like XP, 2000, 2003, etc., try NTFS Link.

I use it a lot. You get a shell link right click menu option to create a junction point. Excellent stuff.

2
  • This worked great for me on Windows 2003 for creating a symbolic link to a folder on another drive. Thanks!
    – Phil
    Nov 13, 2011 at 18:54
  • Comment from anonymous user, originally edited into the answer: "Note: For XP to work, it has to be using an NTFS partition, not FAT or FAT32. See aumha.org/win5/a/ntfscvt.php for steps on how to convert to NTFS."
    – squillman
    Aug 17, 2012 at 19:32
2

See TechNet entry. I believe it is a Vista/Server 2008 and up feature.

1
  • Cool, never known about this feature before, thanks for the link, could be so much usefull!!! May 11, 2009 at 18:11
1

To make sure your links work you might want to check the configuration of your server. Links can be made but unless you use the symlinkevaluation setting in the following command your links might not work.

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

See also http://technet.microsoft.com/en-us/library/cc754077%28v=ws.10%29.aspx. By default only the local options are activated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .