Microsoft

Answers to some common questions about symbolic links

Greg Shultz provides detailed answers to the most common questions he received last week about symbolic links.

In last week's blog, "Be More Efficient and Better Organized with the MKLink Symbolic Link Tool," I provided a brief introduction to the concept of symbolic links and then jumped right into how to use the MKLink command in Microsoft Windows Vista and Windows 7 to create them. After the blog post was published, many folks sent me e-mail or posted questions in the discussion thread asking for a deeper understanding of how symbolic links work within the Windows Vista and 7 operating systems.

Therefore, in this week's edition of the Windows Desktop Report, I'll provide detailed answers to the most common questions I had about symbolic links.

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

What makes symbolic links different from standard shortcuts?

The one question that a lot of folks asked is "What's the difference between a symbolic link and a standard shortcut? They both seem to do the same thing."

Well, standard shortcuts and symbolic links do, in fact, perform a similar function, but there are several differences. To begin with, a symbolic link is a pointer that works at the file-system level as opposed to a shortcut, which is a pointer designed to work within explorer.exe. Since a symbolic link is essentially grafted to the file system, it doesn't have a footprint, so to speak, whereas a shortcut is an actual file on the hard disk.

Take a look at the Properties dialog boxes shown in Figure A. As you can see, the shortcut is an actual file that takes up 4KB of disk space. The symbolic link uses 0 bytes.

Figure A

Shortcuts are files, and symbolic links are part of the file system.

Another difference is that a shortcut is fundamentally a one-shot deal, while a symbolic link has a sustained existence. To see this in action, let's suppose that you use the MKLink command

Mklink /J C:\CurrentWork "C:\Users\Greg Shultz\My Documents\Articles\TechRepublic\2010\9) September 10\9-3"

to create the C:\CurrentWork symbolic link folder that points to the path:

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

Then, you use the Create Shortcut wizard to create a shortcut called CurrentWork Shortcut that points to the same path.

If you double-click the CurrentWork Shortcut, you'll see that the shortcut will deliver you to the 9-3 folder, but if you double-click the CurrentWork symbolic link, you'll see the operating system makes it appear that the files actually exist in the CurrentWork folder, as shown in Figure B. The shortcut has done its job and is gone, while the symbolic link continues working.

Figure B

Once a shortcut does its job, it's gone, but a symbolic link continues working.

(This also works from the Save and Open dialog boxes of your applications. The efficiency improvement then comes from the fact that no matter where you are, all you have to remember is the name of the symbolic link.)

If you work from the command prompt, you'll discover that you can access symbolic link folders on the command line, as shown in Figure C. You can't really use a shortcut from the command line.

Figure C

You can access symbolic link folders from the command prompt.

Windows Vista and Windows 7 have built-in symbolic links

Many other folks wrote in to ask why they couldn't use many of Windows Vista's and Windows 7's built-in symbolic links. For example, if you try to access the C:\Documents and Settings symbolic link folder, you'll see an error message like the one shown in Figure D.

Figure D

You'll encounter an Access is Denied error message from some built-in symbolic links.

To begin with, under normal circumstances, you wouldn't even see the operating system's built-in symbolic links, unless you enable the Show Hidden Files, Folders and Drives option on the View tab of the Folder Options dialog box. Unfortunately, many folks do so and thus end up trying to use the built-in symbolic links. However, these symbolic links are not designed for end users; they're designed to provide backward compatibility for older applications.

Windows Vista and Windows 7 have two types of built-in symbolic links designed for backward compatibility called System Junctions and Per-User Junctions.

An example of a System Junction is C:\Documents and Settings. In Windows XP there is an actual folder called Documents and Settings that contains the user profile folders. In Windows Vista and Windows 7, the user profile folders are stored in a folder called C:\Users, as shown in Figure E.

Figure E

User profiles in Windows Vista and Windows 7 are stored in the C:\Users folder.

However, in order to be backward compatible with older applications that are hard-coded to look for and use the C:\Documents and Settings folder in order to access user profiles, both Windows Vista and Windows 7 create a C:\Documents and Settings symbolic link folder that actually points to C:\Users. This allows the older application to think that it is using the C:\Documents and Settings folder when it is actually using the more streamlined C:\Users folder.

An example of a Per-User Junction is C:\Users\Greg Shultz\My Documents. In Windows XP there is an actual folder called My Documents. In Windows Vista and Windows 7, that folder is now called Documents. In order to be backward compatible with older applications that are hard-coded to look for and use the My Documents folder to open and save files, both Windows Vista and Windows 7 create a My Documents symbolic link.

What's your take?

Do these answers give you a better understanding of how symbolic links work in Windows Vista and Windows 7? As always, if you have comments to share or more questions 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!

About

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