We’ve been huge fans of symlinks for forever, and even posted about Windows Vista’s new mklink commandline utility with quite the passion back in 2006 when the ability to create soft-links from the commandline was first added to Windows.
However, there are a few things that have forever irked us about the ln lookalike called mklink.exe:
- It’s called mklink and not ln. (I mean, you just get can’t get around that fact)
- The arguments are switched around. `mklink something_doesnt_exist actual_file` is just…….. wrong!
- By default, mklink will create softlinks and not hardlinks. ln requires the /h flag to create a hardlink.
- mklink isn’t smart enough to distinguish between files and folders. You need explicitly tell it via the commandline.
- Even then, mklink has two different switches depending on the type of directory link you want. /D for softlink’d directories, and /J for hardlink’d directories.
- mklink can’t be used outside of cmd.exe (such as in PowerShell). (Hat tip: Jason)
- And, of course, mklink isn’t open source.
So we made our own.
ln-win is available in 32-bit and 64-bit, uses the same syntax, names, switches, and argument ordering as ln on *nix. And pursuant to our promise to contribute more to open source, ln-win and our Junction Point library is 100% open source, freely licensed under the generous terms of the MIT license.
Perhaps more importantly, ln-win contains an open source Junction Point library. While Win32 APIs exist to create symlinks (on Vista and up), there is no API for creating hardlinks of any kind (for files or folders). The NeoSmart JunctionPoint library provides the following APIs:
bool CreateJunctionPoint(LPCTSTR origin, LPCTSTR junction); bool IsDirectoryJunction(LPCTSTR path); bool GetJunctionDestination(LPCTSTR path, OUT LPTSTR destination); bool DeleteJunctionPoint(LPCTSTR path);
As you can see, the NeoSmart JunctionPoint library provides all the APIs you need both to create and interact with hardlinks. IsDirectoryJunction can be used for both symlinks and hardlinks, making it a snap to make your code symlink/hardlink aware, letting you intelligently avoid cyclic paths and data duplication for any filesystem traversal needs.
Binaries for Windows x86 and x64

every heard of “ln” and “link shell extension” made by hermann schinagl?
works like a charme
http://schinagl.priv.at/nt/ln/ln.html
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html
-e :)
@neosmart: neat! just tried it out, works great. And the source code is clean, thanks!
@randomcore: doesn’t look like Hermann’s tool is open source. And it doesn’t use the same syntax as the unix ln, either.
As a sysadmin, I always get frustrated when I forget the order of commandline arguments for mklink. This is awesome!
Thanks :)
I guess this won’t work on XP because symlinks were introduced in Vista?
someone: that’s correct. If there’s enough demand, we’ll make it work on XP in “backwards-compatibility mode,” i.e. hardlinks only for both files and folders.
Thanks for this! I never could remember the name of the Windows one, let alone it’s syntax.
Thanks for the write,I myself like and support open source but this is my first time encountering In-win and mklink. Another new discovery for me.
Viva open source!
Thanks for this. Also, you could have added to your bullet points that PowerShell doesn’t have a mklink as mklink is build into cmd.exe.
Great work. Great spirit.
Thank you very much sharing your hard work !
We, outta there, really appreciate it !