How do I create a symbolic link in Windows?

Solution 1:

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.

Solution 2:

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


Solution 3:

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

Solution 4:

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.


Solution 5:

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.