Recipe9.10.Creating a Registry Link


Recipe 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 key. What I could do is create a key called HKEY_LOCAL_MACHINE\Software\Rallencorp and then put all of my registry links under it. Here is an example of creating a link to the Run key:

regln HKLM\Software\Rallencorp\Run HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

See Also

More information about the regln command can be found at http://www.tenox.tc/out/regln.txt.



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net