MKLink Explained: Create Symbolic Links that Simplify File Management in Windows Vista, 7 and 8
Whether you're a casual Windows user or a busy app developer, one of the most essential aspects of improving productivity and organization within an operating system is to give yourself (or the apps you're developing) easy access to the appropriate files/folders and their associated file paths.
If you've used any version of Windows more than a few times, then you've probably already encountered shortcuts – icons/symbols that represent a file or folder located elsewhere on the hard drive. Most programs automatically create a shortcut on the Desktop upon being installed.
When used properly, well-structured shortcuts can save a tremendous amount of time and navigational frustration. In Windows Vista, 7 and 8 there is a more advanced way to create and manage shortcuts using a command line tool known as MKLink.With MKLink you can type a single line of code into the Command Prompt and create three different kinds of shortcuts – Hard Links, Directory Junctions, and Symbolic Links – the latter of which we'll be covering below:
What is a Symbolic Link?
A symbolic link is a type of shortcut in which one object (i.e.- file or folder) points to another object within the file-system. In other words, you click on File1.exe, but File2.exe launches instead.
Symbolic linking with the MKLink tool is particularly useful when you're repeatedly accessing files/folders with lengthy file paths.
For example, you could create a shortcut to a deeply archived folder by adding a succinct symbolic link file to your desktop, thereby ensuring much quicker and more convenient access, especially when compared to having to repeatedly re-navigate to a complicated file path.
Symbolic links differ from conventional shortcuts in that they appear to be typical files/folders to both humans and apps – developers and techies can use symbolic links to change the way their applications behave in regard to utilizing specific files and folders.
Using MKLink Commands to Manage Symbolic Links in CMD.exe
First, by default you'll need administrative privileges to utilize the MKLink tool in the Command Prompt. It is possible to change the “User Rights Assignment” settings to allow non-elevated use of MKLink, but you would need administrative privileges to change those settings. A temporary workaround is to navigate to CMD.exe within Windows Explorer, right-click on the file, and click "Run as Administrator." If you have administrative privileges and you want to give all users the right to create symbolic links, you can follow these steps to allow non-administrator use of MKLink in your installation of Windows:
1. Go to Start Menu > Programs > Accessories > Run.
2. In the Run module, enter in "secpol.msc" (this will launch the Local Security Policy Editor), or alternatively you can enter in "gpedit.msc" (this will launch the Local Group Policy Editor). Both of these modules will provide access to User Rights Assignment settings.
3. Once you're running one of the aforementioned policy editors, navigate to Security Settings > Local Policies > User Rights Assignment
4. On the right side you'll see a list of policies. Double-click the line that says “Create symbolic links"
5. In the dialog box that appears, select “Administrators”
6. Click 'Remove'
7. Click 'OK' to exit the dialog and save the settings
Here's a screenshot of step 3 - navigating to the 'Create symbolic links' policy settings within the Local Group Policy Editor (gpedit.msc):
Next, to launch MKLink - click on the Start menu, type 'CMD.exe' into the Search bar, and press Enter (or, if you are not logged into an administrator account, you can right-click on CMD.exe and select "Run as Administrator" from the context menu). The MS-DOS Command Prompt dialog box will appear. When it does, type “mklink” and press Enter. A guide to the possible parameters will show up looking like this:
To create a symbolic link to a file, type:
- MKLINK Example1.exe Example2.exe
In the scenario above, replace Example.exe with the name of the file you want to serve as the link, replace Example2.exe with the name of the file you are trying to link to.
To create a symbolic link to a folder, type:
- MKLINK /D c:\ExampleFolder1 c:\ExampleFolder2\ExampleFolder3
In the scenario above, replace c:\ExampleFolder1 with the destination of the folder you want to serve as the link. Replace c:\ExampleFolder2\ExampleFolder3 with the destination of the folder you are trying to link to.
Using Software to Execute MKLink Commands
If manually typing 3-inch file paths into the Command Prompt just isn't your thing, you might want to go the easier route by using an app that can interface with the MKLink tool to allow for simplified symbolic linking within a user-friendly GUI. Your top three choices for such an app are:
This tiny utility is a basic symbolic link creator that takes the hassle out of the entire process. The screenshot below says it all:
This software lists three types of reparse points – symbolic links, mount points, and junction points. You also have the option to create new reparse points by opening the 'Create' module shown in the right side of the screenshot below:
Another junction management app that gives you a convenient GUI in which to create symbolic links and other types of hard links. Once again, the screenshot reveals self-explanatory functionality:
If you're still wanting to learn more about the types of tricks you can do with the MKLink tool, check out this in-depth guide from a tech-savvy YouTube user: