Site icon Ryadel

Symbolic Links - Create Folder / Directory Alias in Windows

Triangolo giallo sull'icona Rete di Windows: cosa significa e come eliminarlo

In this post we'll explain the concept of symbolic links, a neat feature available in NFTS-enabled Windows operating system that can be used to create "proxies" or "pointers" for files or folders located elsewhere. In a nutshell, a symbolic link is a file-system object that has the sole purpose to point to another file system object: the object acting as a pointer is the symbolic link, while the one being pointed to is called target.

If you think that we're talking about shortcuts, you're wrong: although there are indeed similarities between the two concepts, the actual implementation is completely different. To better understand these kinds of difference, though, is advisable to step back and talk about what aliases and shortcuts actually are and how they do differ in a typical operating system.

Introduction

In general terms, an alias is defined as an alternate name for someone or something: the noun is derived from the Latin adverb alias, meaning "otherwise" and, by extension, "also known as" (or AKA). In information technology, and more specifically in programming languages, the word alias is often used to address an alternative name for a defined data item, which can be defined only once and then referred by one or multiple aliases: such item can be an object (i.e. a class instance), a property, a function/method, a variable, and so on. In short words, we can say that an alias is an alternate (and arguably most efficient) way to reference to the same thing. This eventually led to a more widespread usage, also including e-mail aliases - a feature of many MTA services that allows to configure multiple e-mail prefixes for a single e-mail account -  and other implementations based upon the overall concept.

The main characteristic of an alias lies in the fact that it is an alternative reference to  the same item: it different from other common terms frequently used in information technology, such as the shortcut - which defines a quicker way to reach - yet not reference to - a given item, target, or goal. To explain it even better, we could say that the alias is a different way to address something, while the shortcut is a different way to reach it. Such difference can be trivial or very important, depending of what we need to do.

Shortcut vs Simbolic Links

The perfect example to visualize the differences between shortcuts and aliases is a typical Windows operating system. From the desktop to the start menu, a Windows environment is tipically full of shortcuts: we do have shortcuts to run programs, to look into the recycle bin, to open a folder (which can contains other shorcuts), and so on. In a nutshell, a Windows shortcut is basically just a file that tells Windows what other file needs to be opened whenever it gets clicked, executed or activated: we could just say that a shortcut is a physical resource designed to redirect to another (different) resource: it help us to get there, yet it's not an alternate way to address it. This means, for example, that its reference won't be affected if we delete it. It also means that we can change its reference at any time, without altering its status (it will still be a shortcut) and without affecting its previous reference (cause they are completely different things and not related in any way).

An alias doesn't work like that: whatever command we issue to it would likely have effect on the actual item to which it refers: we could say that an alias is a different (and additional) path to access the same resource. As a matter of fact, it ultimately depends on how the alias feature has been implemented on that specific scenario we're dealing with, but that's how it usually works in most programming languages, operating systems, database services and similar IT environments that usually make use of the concept. That's how it works on UNIX, where aliases are called links, and also in Windows NTFS, where they are known as symbolic links.

Shortcuts

In modern Windows, a shortcut is an handle that allows the user to find a file or resource located elsewhere. Microsoft Windows introduced such concept in Windows 95 with the shell links, which are still being used nowadays: these are the files with the .lnk extension you most likely already know (the .url extension is used when the target is a remote location, such as a web page). Microsoft Windows .lnk files operate as Windows Explorer extensions, rather than file system extensions.

From a general perspective, a shortcut is basically a regular file containing path data: we can think on them as text files which only contain a URI for a file, a folder or any other external resource (UNC share, HTTP(s) address, and so on): that URI gets executed whenever the user clicks on (executes) them, as long as the operating system allows it - which is the default behaviour by default, but can be disabled for security reasons. Anyway, shortcuts are treated like ordinary files by the file system and by software programs that are not aware of them: only software programs that understand what shortcuts are and how they work - such as the Windows shell and file browsers - are able to "properly" treat them as references to other files.

Symbolic Links

Conversely from aliases, NTFS symbolic links (also known as symlink) have been implemented to function just like the UNIX aliases: for that very reason, they are transparent to users and applications. They do appear just any other standard file or folder, and can be acted upon by the user or application in the same manner. Such "transparency" makes them perfect to aid in migration and/or application compatibility tasks: whenever we have to deal with an "hardcoded" path that cannot be changed, and we don't want to physically move our files there, we can create a symbolic link pointing to that address and fix our issue for good.

How to create Symbolic Links

On Windows Vista and later, including Windows 10, symbolic links can be created uisng the mklink.exe command-line tool in the following way:

Here's an explanation of the relevant parameters:

  • /d – This parameter creates a directory symbolic link. mklink creates a file symbolic link by default.
  • /h – This parameter creates a hard link instead of a symbolic link.
  • /j – This parameter creates a Directory Junction.
  • <Link> – This parameter specifies the name of the symbolic link that is being created.
  • <Target> – This parameter specifies the path that the new symbolic link refers to.
  • /? – This parameter displays help.

In Windows XP, where mklink.exe is not available, you can use the junction utility by Mark Russinovich, now offered by Microsoft as a part of their official Sysinternals suite (download link).

It's worth noting that, as a viable alternative of mklink.exe, in Windows Vista and later you can also use the New-SymLink Powershell function.

Conclusion

That's pretty much about it: we hope that this small guide will be useful for those who're looking for a way to create symbolic links and/or to gain valuable info regarding aliases and shortcuts.

 

Exit mobile version