9.10. Creating a Registry Link

Problem

You want to create a link from one registry key to another. Registry links are used extensively by the operating system, but most people aren't aware that they exist and that they can even be created manually.

Solution

Using a command-line interface

Registry links have never been a highly publicized feature and as a result, there are very few tools that can create them. You can download a tool called regln from http://www.ntinternals.net/regln/ to do the job. This is how you create a registry link with it:

> regln  <LinkKeyName> 
                  <CurrentKeyName>

For example:

> regln HKLM\SOFTWARE\Rallencorp\Current HKLM\SOFTWARE\Rallencorp\Settings1

Use the -d switch to delete a registry link:

> regln -d <LinkKeyName>

For example:

> regln -d HKLM\SOFTWARE\Rallencorp\Current

Using VBScript

The StdRegProv WMI Provider does not support creating registry links, so you'll need to shell out to regln if you want to create them in a script.

Discussion

You have undoubtedly created a shortcut to a file or folder, perhaps on your desktop, at one point or another. Shortcuts are useful if you have a file that is nested deeply within the filesystem and you don't want to navigate to it each time to access it. Think of registry links in the same way. If there are deeply nested registry keys you need to access on a regular basis, you can use a registry link to make it easier to reach.

Let's say there are a bunch of keys I frequently access that are contained somewhere under the HKEY_LOCAL_MACHINE\Software ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.