Windows Create Symbolic Links
Want to easily access folders and files from different location without maintaining duplicate copies? Here’s how you can use Symbolic Links to link anything in Windows 10, 8, 7, Vista and XP.
So What Are Symbolic Links Anyway?
Symbolic links, otherwise known as symlinks, are basically advanced shortcuts. You can create symbolic links to individual files or folders, and then these will appear like they are stored in the folder with the symbolic link even though the symbolic link only points to their real location.
There are two types of symlinks: soft, which act as a simple redirect or shortcut, and hard, which make it appear that the file or directory exist in the location of the symlink. Hard symlinks make the new location totally transparent to the application.
Why should I use Symbolic Links?
There are many things we use symbolic links for, so here’s some of the top uses we can think of:
- Sync any folder with Dropbox
- Move the settings folder for any program from its original location
- Store your Music/Pictures/Videos on a second hard drive, but make them show up in your standard Music/Pictures/Videos folders so they’ll be detected my your media programs (Windows 7 Libraries can also be good for this)
- Keep important files accessible from multiple locations
- And more!
If you want to move files to a different drive or folder and then symbolically link them, follow these steps:
- Close any programs that may be accessing that file or folder
- Move the file or folder to the new desired location
- Follow the correct instructions below for your operating system to create the symbolic link.
Caution: Make sure to never create a symbolic link inside of a symbolic link. For instance, don’t create a symbolic link to a file that’s contained in a symbolic linked folder. This can create a loop, which can cause millions of problems you don’t want to deal with. Seriously.
Symlinks via Command Prompt
Here’s how you can create symlinks in Command Prompt in any version of Windows.
Windows 10, 8, 7, or Vista
In Windows Vista and 7, we’ll use the mklink command to create symbolic links. To use it, we have to open an administrator Command Prompt. Enter “command” in your start menu search, right-click on Command Prompt, and select “Run as administrator”.
To create a symbolic link, we need to enter the following in command prompt:
mklink /prefix link_path file/folder_path
First, choose the correct prefix. Mklink can create several types of links, including the following:
- /D – creates a soft symbolic link, which is similar to a standard folder or file shortcut in Windows.
- /H – creates a hard link to a file
- /J – creates a hard link to a directory or folder
So, once you’ve chosen the correct prefix, you need to enter the path you want for the symbolic link, and the path to the original file or folder.
For example, if I wanted a folder in my Dropbox folder to appear like it was also stored in my desktop, I would enter the following:
mklink /J C:\Users\User\Desktop\Dropbox C:\Users\User\Documents\Dropbox
Note that the first path was to the symbolic folder I wanted to create, while the second path was to the real folder. If your path has any spaces in it, you need to place quotes around it. Note also that the link can have a different name than the file it links to. For example, here I’m going to create a symbolic link to a document on my desktop:
mklink /H “C:\Users\User\Desktop\ebook.pdf” “C:\Users\User\Downloads\Some Book.pdf”
In Windows XP
Windows XP doesn’t include built-in command prompt support for symbolic links, but we can use the free Junction tool instead. Download Junction Application, and unzip the folder. Now open Command Prompt (click Start, select All Programs, then Accessories, and select Command Prompt), and enter cd followed by the path of the folder where you saved Junction./
Junction only creates hard symbolic links, since you can use shortcuts for soft ones. To create a hard symlink, we need to enter the following in command prompt:
junction –s link_path file/folder_path
As with mklink in Windows 7 or Vista, if your file/folder path has spaces in it make sure to put quotes around your paths. Also, as usual, your symlink can have a different name that the file/folder it points to. Here, we’re going to create a symbolic link to our My Music folder on the desktop. We entered:
junction -s “C:\Documents and Settings\Administrator\Desktop\Music” “C:\Documents and Settings\Administrator\My Documents\My Music”
And here’s the contents of our symlink. Note that the path looks like these files are stored in a Music folder directly on the Desktop, when they are actually stored in My Documents\My Music. Once again, this works with both folders and individual files.
Please Note: Junction would work the same in Windows 7 or Vista, but since they include a built-in symbolic link tool we found it better to use it on those versions of Windows.
Symlinks in Explorer with Link Shell Extension
Creating symlinks is usually difficult, but thanks to the free Link Shell Extension, you can create symbolic links in all modern version of Windows pain-free. There is a tool called Link Shell Extension which makes it easy to create symlinks to files, as well as an older type of link called a "Junction" (basically, a symlink to a folder) as well as many more exotic types of links.
Basic usage is simple: Navigate to the source folder, right click on the file or folder you want to link to, and choose the new "Pick Link Source" option from the context menu. Then go to the folder where you want to drop the link, right-click, and select "Drop As" and then either "Symbolic Link" for files or "Junction" for folders.
BEWARE: One reason Microsoft makes it hard to do this is that junctions and symlinks can make it very easy to accidentally DELETE CRITICAL FILES! In some versions prior to Windows 7, deleting a junction or symlink in Explorer would automatically DELETE THE ORIGINAL DIRECTORY as well!