DevLearningTools

MODULE 11 · LESSON 07

cfregistry

Reading, writing, and deleting Windows registry keys and values with <cfregistry>, and the real platform difference: deprecated on UNIX in Adobe ColdFusion, but supported cross-platform in Lucee.

New lessons are added one at a time as the course gets built out — a graded quiz for each lesson is still on the way.

<cfregistry> reads, writes, and deletes keys and values directly in the system registry, the same registry Windows itself and other installed applications store their own configuration in.

Learning Objectives

After completing this lesson, you'll be able to:

  • Read a single registry value, and list every entry under a whole branch at once.
  • Create, update, and delete registry entries with cfregistry.
  • Know the real platform gotcha: this tag behaves very differently on Adobe ColdFusion versus Lucee outside of Windows.

How cfregistry Fits In

Your Code

cfregistry

System Registry

Reading a Single Value

Tag Syntax
<cfregistry action="get"
    branch="HKEY_LOCAL_MACHINE\Software\MyApp"
    entry="InstallPath"
    variable="installPath">
<cfoutput>#installPath#</cfoutput>
CFScript
cfregistry(
    action = "get",
    branch = "HKEY_LOCAL_MACHINE\Software\MyApp",
    entry = "InstallPath",
    variable = "installPath"
);
writeOutput(installPath);
NOTE

If the entry doesn't exist, get simply doesn't populate the variable, it does not create the entry as a side effect.

Listing an Entire Branch

Registry Branch

cfregistry action="getAll"

Query of Entries

Tag Syntax
<cfregistry action="getAll"
    branch="HKEY_LOCAL_MACHINE\Software\MyApp"
    name="settings"
    sort="entry asc">
<cfoutput query="settings">
    #entry# = #value# (#type#)<br>
</cfoutput>

Setting and Deleting Values

Tag Syntax — set
<cfregistry action="set"
    branch="HKEY_LOCAL_MACHINE\Software\MyApp"
    entry="LastRunDate"
    type="string"
    value="#dateFormat(now(), 'yyyy-mm-dd')#">
Tag Syntax — delete
<cfregistry action="delete"
    branch="HKEY_LOCAL_MACHINE\Software\MyApp"
    entry="LastRunDate">
NOTE

set creates the key or value if it doesn't already exist yet, there's no separate "create" action. Deleting a whole key (rather than a single value under it) also deletes every value and subkey defined beneath it, there's no separate confirmation step.

The action Attribute: Full Reference

actionWhat it does
getReads a single value into a variable
getAllReturns a query listing every entry under a branch
setCreates or updates a key or value
deleteRemoves a value, or an entire key and everything beneath it
NOTE

type applies to get, getAll, and set, and accepts string (the default), dWord, key, or any.

A Real Platform Gotcha: Windows vs. Cross-Platform

That's from Adobe's own cfregistry reference, on Adobe ColdFusion this tag is fundamentally tied to the actual Windows registry, and it's deprecated outside Windows for exactly that reason: there's no real registry to read on Linux or macOS. Lucee's own documentation says something genuinely different: "The cfregistry tag is supported on all platforms, including Windows, Linux, Solaris, and HP-UX." Lucee implements its own registry abstraction that works everywhere, rather than depending on an actual Windows-only OS feature.

This tag is deprecated for the UNIX platform.

NOTE

Code written assuming cfregistry always reflects the real OS registry will behave very differently once it's running on Lucee outside Windows, confirm which engine and platform a project actually targets before relying on this tag for anything beyond Windows-specific configuration.

Common Beginner Mistakes

Assuming action="get" creates the entry if it doesn't already exist

It doesn't, get only reads. If the entry is missing, the target variable is simply never populated.

Deleting a key without realizing everything beneath it goes too

Deleting a key also deletes every value and subkey defined under it, per Adobe's own documentation, there's no separate step or confirmation.

Relying on cfregistry for real OS-level configuration on a non-Windows Adobe ColdFusion server

Adobe's own documentation calls this tag deprecated on UNIX. It's genuinely Windows-registry-specific there, not just discouraged.

Assuming cfregistry works identically on Lucee outside Windows

Lucee implements a registry abstraction that works cross-platform, unlike Adobe ColdFusion's tag, which is tied to the actual Windows registry. The two engines behave meaningfully differently here.

Best Practices

  • Use cfregistry for genuinely Windows-registry-specific needs, not as a general-purpose settings store for an application that might run cross-platform.
  • Double-check whether a delete targets a single value or an entire key, before running it against anything important.
  • Confirm which CFML engine and OS a project actually targets, given how differently Adobe ColdFusion and Lucee treat this tag outside Windows.
  • Prefer an application-level configuration file or database table over the registry for settings that need to be portable across environments.

Interview Questions

What's the difference between cfregistry's get and getAll actions?

get reads one specific value into a variable. getAll returns a query listing every entry under an entire branch at once.

What happens if you delete a registry key rather than a single value?

Every value and subkey defined beneath that key is deleted along with it, per Adobe's own documentation, there's no separate confirmation or partial-delete step.

Why is cfregistry described as deprecated on UNIX in Adobe ColdFusion specifically?

Because it's tied to the actual Windows system registry, which doesn't exist on UNIX-like systems at all.

How does Lucee's cfregistry differ from Adobe ColdFusion's on non-Windows platforms?

Lucee implements its own cross-platform registry abstraction, explicitly documented as supported on Windows, Linux, Solaris, and HP-UX, rather than depending on a real Windows-only OS feature the way Adobe ColdFusion's version does.

Summary

In this lesson, you read a single registry value and listed an entire branch at once, created, updated, and deleted registry entries, and covered a real, meaningful platform difference: Adobe ColdFusion's cfregistry is genuinely Windows-registry-specific and deprecated on UNIX, while Lucee implements a cross-platform abstraction that behaves differently outside Windows.

What's Next?

That completes Module 11: Files. The next module moves into error handling, starting with try/catch.