Software

How to take advantage of symbolic links in Windows 10

Symbolic links can save you a lot of time, and the Windows 10 command-line tool MKLink makes it easy to create them. Here are several examples of how you can put symbolic links to work.

grapixistock-517308945.jpg

Image: iStock/grapix

If you read my last article How to access desktop themes in Windows 10 Creators Update, you know that I was planning on following up that article with one that would show you how to create custom themes. However, as I was exploring that technique I got sidetracked by a question I received from a reader who was interested in learning more about symbolic links.

I promise that I will get back to the creating custom themes article soon. But let's take a closer look at how to create and use symbolic links in Windows 10.

What is a symbolic link?

If you've been using Windows for quite some time, chances are good that you create and use shortcuts regularly. Shortcuts can save you time and effort when it comes to quickly accessing applications or folders. While creating and using these types of standard shortcuts is simple, Windows also comes with a little command-line tool call MKLink, which allows you to create a more advanced type of shortcut called a symbolic link.

More specifically, a symbolic link is a file system object that points to another file system object. The object can be either a file or a folder. Symbolic links are transparent to users—the links appear as normal files or folders and can be accessed by applications and users in exactly the same manner. Keep this thought in mind as we explore MKLink tool.

SEE: 50 time-saving tips to speed your work in Microsoft Office (TechRepublic PDF)

The MKLink tool

To use the MKLink tool, you have to open a command prompt in administrator mode. Here's the easiest way to do so:

  1. Click the Start button.
  2. Type CMD in the Start Search box.
  3. Press and hold down [Ctrl]+[Shift]+[Enter].

A UAC dialog box will appear, and you'll have to respond accordingly.

When the Administrative Command Prompt window appears, just type mklink and you will see the tool's syntax description, as shown in Figure A.

Figure A

Figure A
Using the MKLink tool on the command line is easy.

How it works

As an introduction to the MKLink tool, let's take a quick look at how its options work for creating symbolic links.

If you use the base command without any options, you can create a symbolic link to a file. For example, the command:

mklink pad.exe notepad.exe

will create a file symbolic link so that typing pad.exe will allow you to launch notepad.exe.

Using the /D option will create a symbolic link to a folder. For example, the command:

mklink /D c:\fruit c:\apples\bananas\oranges

will create a symbolic link called fruit that points directly to the folder oranges.

The /H option will create a hard link rather than a symbolic link. The difference between a hard link and a standard symbolic link is that instead of working like a shortcut, a hard link is more like renaming the file. For example, the command:

mklink /H pad.exe notepad.exe

will make the operating system treat pad.exe as if it were actually notepad.exe.

Finally, the /J option will create a hard link to a folder. This is also called a directory junction (a.k.a. junction point) and instead of working like a shortcut to a folder, a hard link works more like a regular folder. For example, the command:

mklink /J c:\fruit c:\apples\bananas\oranges

will make the operating system work with the long directory structure c:\apples\bananas\oranges just as if it were a single directory named c:\fruit.

If you have been following along and creating any of these types of symbolic links, you can terminate the link simply by deleting it. For instance, to terminate the fruit hard link, you'd simply delete the c:\fruit folder. However, since the link is terminated first and c:\fruit folder is actually empty, you needn't be concerned about data loss in the c:\apples\bananas\oranges folder.

SEE: Windows 10 power tips: Secret shortcuts to your favorite settings (Tech Pro Research)

My CurrentWork example

Back in the Windows 2000 days, I developed my CurrentWork folder-management technique to reduce the amount of time I spent navigating my detailed folder organizational structure. To do so, I used a command-line tool called Linkd.exe from the Windows 2000 Resource Kit. However, because the MKLink tool comes with Windows 10, anyone can use it.

To implement my technique in Windows 10, I use MKLink to generate a symbolic link that creates the C:\ CurrentWork folder and redirects it to a folder deeply nested in the folder structure I use to keep my work organized. For example, the target folder could have the path:

C:\Users\Greg\Documents\1) My Work\1-Writing\1) TechRepublic\1) Articles\2017\10) October 17\10-2

As I finish an article, I remove that symbolic link and create a new one for the next article. Of course, this means that the target folder is always changing as I move from week to week. However, once I create the new symbolic link, the only folder name I have to navigate to when opening, saving, or copying files related to the assignment is the C:\ CurrentWork folder. This has saved me an immeasurable amount of time and frustration.

For example, before writing this article, I used the command:

Mklink /J C:\CurrentWork "C:\Users\Greg\Documents\1) My Work\1-Writing\1) TechRepublic\1) Articles\2017\10) October 17\10-2"

Since I'm working on the command line and the target path contains long names with spaces, I have to enclose the target path in double quotes. But even though the path is long, while I was working on this article, the only folder I had to remember was CurrentWork.

Also read...

What's your take?

Now that you know how easy it is to create your own symbolic links, will you apply this technique to the way you work? Are you already using symbolic links and the MKLink tool in Windows 10? If so, what has been your experience? Share your thoughts with fellow TechRepublic members.

About Greg Shultz

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks

Free Newsletters, In your Inbox