Creating symbolic links in Windows Vista and Windows 7
First published on June 17, 2010
A symbolic link (or “symlink”) is quite useful to have a file system treat a file or folder like it is in a specific location, when the file or folder actually resides elsewhere. Some of my recent uses for symbolic links include having Dropbox sync files outside of its parent directory; and having programs and websites use files checked out via SVN elsewhere. Symbolic links can come in handy in some lesser technical situations as well, as a tool to keep your digital files organized.
In Windows XP and lower, if you wanted to create something similar to a Unix symbolic link (the “ln -s” command) you would have to look into things like junction points, which were poorly documented and required some mysterious plugins or add-ons.
In Windows Vista and higher, you can use the “mklink” function on the command line. Its basic syntax is: “mklink newlinkname target”, and one of the parameter options is “/D” if you’re creating a directory symbolic link. For example, I was working on a website at c:\www\site which needed to have a folder that sat at c:\www\shared\extension; “extension” needed to stay in its original location. On the command line under the “site” folder, I used “mklink /D extension ..\shared\extension”. In the image below, you can see the contents of c:\www\site; the symbolic links have the same icons as shortcuts do. However, instead of normal Windows shortcut, browsing “extension” would open that folder as if all of its contents were actually at c:\www\site\extension.
This way, when I browse c:\www\site\extension, it’s as if the “extension” folder was actually there. If any edits (including deletions) are made within that folder, it is reflected in its original location and also its symbolic location.
“mklink” is well-explained a bit more here and here.