If you are like most folks who have been using Microsoft Windows for quite some time, chances are good that you create and use shortcuts quite regularly. As you know, 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 quite simple, Windows 7 and Vista come with a tool called MKLink for creating a more advanced type of shortcut called a symbolic link.

In this edition of the Windows Desktop Report, I’ll explain in more detail what a symbolic link is and show you how to use the MKLink tool. I’ll then show how I use symbolic links to simplify file management.

This blog post is also available in PDF format in a TechRepublic download.

What is a symbolic link?

As I alluded to in the introduction, a symbolic link is essentially a more advanced type of shortcut. More specifically, a symbolic link is a file-system object that points to another file system object. The file system object can be either a file or a folder. Symbolic links are transparent to users because the links appear as normal files or folder and can be accessed by applications as well as users in exactly the same manner. Keep this thought in mind as we explore MKLink tool.

The MKLink tool

In order to use the MKLink tool, you have to open a command prompt in administrator mode.

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

When you do, you will encounter a UAC dialog box and will have to respond accordingly.

When the Administrative command prompt window appears, just type mklink and you will see the tools syntax description, as shown in Figure A.

Figure A

Using the MKLink tool on the command line is easy.

As you can see, the default command (without any options) will create a symbolic link to a file. For example, the command:

mklink pad.exe notepad.exe

will create a file symbolic link where 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:\one c:\two\three\four

creates a symbolic link called one, which points to the folder called four.

The /H option will create a hard link rather than a symbolic link. The difference between a hard link and a 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

makes 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:\one c:\two\three\four

makes the operating system work with the long directory structure c:\two\three\four just as if it were a single directory named c:\one.

When you’re finished with any one of these types of symbolic links, you can terminate the link simply by deleting the link. For example, to terminate the one hard link, you’d simply delete the c:\one folder. However, since the link is terminated first and c:\one folder is actually empty, you needn’t be concerned about data loss in the c:\two\three\four folder.

The CurrentWork example

Back in the Windows 2000 days, I developed my CurrentWork file-management technique to reduce the amount of time and effort I spent navigating my very detailed-oriented folder organizational structure. To do so, I used a command-line tool called Linkd.exe from the Windows 2000 Resource Kit. (The old Linkd tool worked similarly to the current MKLink tool.) Now that I’m using Windows 7, I’m using the MKLink tool.

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

C:\Users\Greg Shultz\My Documents\Articles\TechRepublic\2010\9) September 10 \9-3

As I finish an assignment, I remove that symbolic link and create a new one for the next assignment. Of course, this means that the target folder is always changing as I move from assignment to assignment. 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 Shultz\My Documents\Articles\TechRepublic\2010\9) September 10\9-3”

As you can see, 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. However, even though the path is very long, while I was working on this article, the only folder I had to remember was CurrentWork.

What’s your take?

Now that you see how easy it is to create your own symbolic links, will you apply this example to the way you work? Are you already using symbolic links and the MKLink tool in Windows 7? If so, what has been your experience? As always, if you have comments or information to share about this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you.

Stay on top of the latest Microsoft Windows tips and tricks with TechRepublic’s Windows Desktop newsletter, delivered every Monday and Thursday. Automatically sign up today!