Deleting Registry Keys and Values

There are times when you might find it desirable to delete information from the system registry, for example, if you want to delete a data source without having to go through the ColdFusion Administrator. The CFREGISTRY tag can delete a registry value, a single registry key or an entire registry branch by setting the ACTION attribute to Delete. But it is extremely important to know what you are doing with regards to the registry before you use this action. You should also have a current backup of your registry before using the CFREGISTRY tag to delete registry entries. Example 21-7 deletes an entry from the registry.

Example 21-7. Deleting a Registry Value

<CFREGISTRY ACTION="Delete"
          BRANCH="HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion"
          ENTRY="Test">

<CFREGISTRY ACTION="GETALL"
          BRANCH="HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion"
          NAME="GetCurrent" TYPE="Any" SORT="ASC">

<H3>HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion</H3>

<TABLE BORDER="1">
<TR>
  <TH>Entry</TH><TH>Type</TH><TH>Value</TH>
</TR>

<CFOUTPUT QUERY="GetCurrent">
<TR>
  <TD>#Entry#</TD><TD>#Type#</TD><TD>#Value#</TD>
</TR>
</CFOUTPUT>
</TABLE>

In Example 21-7, we set the ACTION attribute of the CFREGISTRY tag to Delete. BRANCH specifies the branch containing the entry we want to delete. The ENTRY attribute specifies the name of the entry we want to delete; in this case, an entry named Test. Note that if the entry specified in Entry doesn’t ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.