Microsoft

Vista's symbolic links feature saves navigating time

Here's a look at Windows Vista's new symbolic links tool -- Mklink.

When I was using Windows XP, I began using a segment of the symbolic links feature called junction points and my CurrentWork file-management technique to reduce the amount of time and effort I spent navigating my very detail-oriented organizational structure for folders. However, since Windows XP didn't provide a native symbolic link utility, I had to borrow a command-line utility called Linkd.exe from the Windows 2000 Resource Kit. While the Linkd utility worked fine in Windows XP, it did have a few drawbacks.

I later began using a program called Junction Link Magic from Rekenwonder Software (http://www.rekenwonder.com). The really nice thing about Junction Link Magic is that it provides a GUI front end that allows you to easily create and delete junction points.

When I moved to Windows Vista, I fully intended to bring Junction Link Magic with me as it is Vista-compatible. However, I decided to first spend some time investigating Vista's new symbolic links tool — Mklink. Let's take a closer look.

My CurrentWork technique

As I mentioned, the main advantage of using junction points is to reduce the amount of time and effort you spend navigating your hard disk in both Windows Explorer and in your application's Open and Save As dialog boxes.

Ever since I discovered the benefits of junction points, I've kept a folder named CurrentWork in the root directory of my NTFS drive. As I begin each new writing assignment, I create a junction point that redirects the C:\ CurrentWork folder 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:\Documents and Settings\Greg Shultz\My Documents\Writing\TechRepublic\2007\04_April\Vista_Report\4-20

As I finish an assignment, I remove that junction point 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 junction point, 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.

The Mklink command

In order to use the Mklink command in Windows Vista, you have to open a command prompt in administrator mode. The easiest way to do so is

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 Command Prompt windows appears, just type mklink and you will see the following syntax description:

MKLINK [[/D] | [/H] | [/J]] Link Target

                Default is a file symbolic link

/D            Creates a directory symbolic link. 

/H            Creates a hard link instead of a symbolic link

/J             Creates a Directory Junction

Link        specifies the new symbolic link name

Target specifies the path (relative or absolute) that the new link refers to

In this case, the default command (without any options) will create a symbolic or soft link to a file, which works very much like a shortcut in Windows XP. For example, the command

mklink pad.exe notepad.exe

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

Using the /D option will create a symbolic or soft link to a folder, which also works like a shortcut in Windows XP. For example, the command

mklink /D c:\one c:\two\three\four

will create a soft link, or a shortcut called one that points to the nested folder four.

The /H option will create a hard link rather than a soft link. The difference here is that instead of working like a shortcut, this 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 is actually notepad.exe.

Finally, the /J option will create a hard link to a folder. This is also called a directory junction or 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

will make the operating system work with the long directory structure c:\two\three\four just as 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.

Not for mixed networks

It's important to keep in mind that Windows Vista's symbolic links feature is only designed for Windows Vista. In other words, if you're running a Windows XP system and connect to a Windows Vista across a network, you wouldn't be able to use any symbolic links.

Using my CurrentWork technique in Vista

Even though using Vista's Mklink means once again working from a command line to create junction points, I've discovered that Mklink is very efficient, offers additional features, and is easy to use. For example, before writing this article, I used the command

Mklink /J C:\CurrentWork "C:\Documents and Settings\Greg Shultz\My Documents\Writing\TechRepublic\2007\04_April\Vista_Report\4-20"

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.

Now that you see how easy it is to create your own junction points, you can apply this example to the way you work. Chances are good that you, too, will reap the benefits once you get into the habit.

Please drop by the Discussion area and let us know what you think about Windows Vista new symbolic links feature.

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