117

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?

cowgod
  • 3,460
  • 6
  • 27
  • 20
  • 6
    Can someone highlight the differences between a symbolic link and a shortcut? – tomjedrz May 12 '09 at 02: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. – Afriza N. Arief Feb 17 '12 at 03: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 http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html and navigate to section "Symbolic links for Windows XP". HTH – Adam Ryczkowski Oct 24 '12 at 06:48

8 Answers8

112

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.

cowgod
  • 3,460
  • 6
  • 27
  • 20
  • Would be nice to add David's Technet url to your entry for completeness. – Michael Pryor May 11 '09 at 18:22
  • site note, what is a juntion (/J option) ? – Roy Rico Sep 22 '09 at 21:06
  • A Directory Junction a type of directory symbolic link. http://support.microsoft.com/?kbid=205524 – Lara Dougan Dec 07 '09 at 08: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 09 '11 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 '11 at 22:13
  • 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 http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html and navigate to section "Symbolic links for Windows XP". HTH – Adam Ryczkowski Oct 24 '12 at 06:49
  • For a link to a folder on another drive I had to add /J. Windows 10. – Franc Drobnič Nov 29 '17 at 09:46
  • ["Starting with Windows 10 Insiders build 14972.. For users who have Developer Mode enabled, the mklink command will now successfully create a symlink if the user is not running as an administrator." (2016)](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/). Otherwise you may get "You do not have sufficient privilege to perform this operation". – Nickolay Aug 10 '21 at 02:40
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

saschabeaumont
  • 2,794
  • 22
  • 14
  • 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 '11 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 05 '15 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
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
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.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
user2287
  • 227
  • 1
  • 2
  • 1
    The command mklink is Vista and Server 2008 and up only, as I pointed out above. –  May 11 '09 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.

romandas
  • 3,242
  • 8
  • 37
  • 44
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.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
Stewart Robinson
  • 1,145
  • 4
  • 12
  • 24
  • This worked great for me on Windows 2003 for creating a symbolic link to a folder on another drive. Thanks! – Phil Nov 13 '11 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 http://aumha.org/win5/a/ntfscvt.php for steps on how to convert to NTFS." – squillman Aug 17 '12 at 19:32
2

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

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.

Cie6ohpa
  • 231
  • 1
  • 6