ACTION=”Set” ColdFusion Help

ACTION-‘ Set’ is a little more complicated than the previous two .actions, simply because it can be employed for two purposes: to update the value of an existing entry, or to create a new entry or key. Regardless of whether it is being used to update or create, the same four additional attributes are available when using AarON-‘ Set ‘
BRANCH.The complete path and name of the location (or branch) to be worked with. This is a required attribute.
ENTRY The name of the value to be updated or the value or key to be created. This is a required attribute.
TYPE Specifies the type of data to return. Possible data types include String (for string values), DWordfor DWord values, and Key for registry. By default, this attribute is set to String.
VALUE The value of an entry being updated or created. If not provided, string values will default to the empty string and DWord values to zero.
“Using these attributes enables you to accomplish the following:·
• To update an existing value, provide the branch, name, and new value for the exising entry.
• To create a new entry, provide the branch, name, and type of the value and optionally provide an initial value for the entry.

To create a new key, provide the branch and key names for the new key and specify TYPE=” Key’

For instance, to change the value of the Reg; steredOrganizati on entry (used earlier withACTION=”Get’) to New Organization, you use the following tag:

ENTRY-‘ Registe redO’rganizati on’
VALUE-‘New Organization’)

Similarly, to create a new sub-key in the same branch called NewApp,use the following tag:


As would be expected, you can use ACTION=’Delete’ to delete an existing entry or key in the registry. Only two attributes are used to do this:
BRANCH The complete path and name of the location (or branch) to be deleted. This is a required attribute.
ENTRY The name of the value or key to be deleted. This is a required attribute.

Enhancing Security

Like other tags such as CFFILE and CFDIRECTORYth,e CFREGISTRYtag poses a potential security risk, especially on systems in which users can create their own templates. In this sort of environment, allowing users to use the CFREGISTRYtag means that any user can manipulate and alter the contents of the registry on the ColdFusion server. When this is an issue, you can use the ColdFusion Administrator to disable the CFREGISTRYtag for all users. To do this, open the Basic Security section of the Administrator, scroll to the bottom of the page, and unselect the Enable CFREGISTRYcheck box.

Building a Registry Viewer

To put everything you’ve learned about the registry together, the rest of this chapter will discuss a simple Web-based registry-viewing tool built in ColdFusion that uses the CFREGISTRY tag. This tool provides a way to view the values in a given key, as well as to open sub-keys from that branch. The template that follows works like this:
• A menu of top-level branches (such as HKEY_CURRENT _MACHINE) is always displayed. The user can select a branch and click the View button to view it.
• If a branch is specified in the URL, then that key is displayed.
• If no branch is specified in the URL and the menu of top-level branches has not been used, then no branch is displayed:
• When a branch is displayed, keys are displayed as links so that they can be viewed in turn.
This process is achieved with the template in Listing 34.1

The template is divided into three main sections:
• Root branch menu
• Querying the registry and displaying the results

Posted on November 17, 2015 in Using the CFREGISTRY Tag

Share the Story

Back to Top
Share This