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?

link|improve this question

4  
Can someone highlight the differences between a symbolic link and a shortcut? – tomjedrz May 12 '09 at 2:46
@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 Feb 17 at 3:55
feedback

7 Answers

up vote 40 down vote accepted

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 are supported on NTFS file systems only and are available in Windows Vista, Windows Server 2008 and Windows 7. Future Windows operating systems are likely to continue support for this command.

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

link|improve this answer
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. support.microsoft.com/?kbid=205524 – Lara Dougan Dec 7 '09 at 8:09
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 '11 at 14:13
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
feedback

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

link|improve this answer
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 – Sebastian Mar 16 '11 at 10:37
feedback

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.

link|improve this answer
The command mklink is Vista and Server 2008 and up only, as I pointed out above. – David Collantes May 11 '09 at 18:12
feedback

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
link|improve this answer
That should be /c, not /k, otherwise cmd.exe won't exit. – dangph Mar 15 '10 at 7:04
feedback

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.

link|improve this answer
Note that ` /linkd` is only for directories, not files. – Phrogz Jul 19 '11 at 22:11
feedback

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

link|improve this answer
Cool, never known about this feature before, thanks for the link, could be so much usefull!!! – Marc-Andre R. May 11 '09 at 18:11
feedback

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.

link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.