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 or that they can 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\LinkToMS HKLM\Software\Microsoft

Use the -d switch to delete a Registry link:

> regln -d <LinkKeyName>

For example:

> regln -d HKLM\SOFTWARE\LinkToMS

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 Registry keys you need to access on a regular basis, but they are nested deeply, you can use Registry links to make them easier to get to.

Let's say there are a bunch of keys I access frequently 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 that key. 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 the following web site: http://www.tenox.tc/out/regln.txt.



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

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