Reference · reference

registry module (Windows)

2 min read · 2026-09-02 · config-weave 0.1.0

use registry reads and writes the Windows registry. The module is registered on every platform, so a playbook compiles and validates identically everywhere; on Linux and macOS every call returns a runtime error. Guard a call with a step condition on os.family or with sys::family() from the sys module. Every function returns Result[…, string]. A key is a hive-prefixed path such as HKLM\Software\Vendor\App; the hive names are also available as the constants registry::HKLM, HKCU, HKCR, HKU and HKCC.

read

rust
registry::read(key: string, name: string) -> Result[Option[Value], string]

Reads a value. It returns None when the key or the value is absent. The Value is typed by the registry kind of the entry.

Registry kindValue
REG_SZ, REG_EXPAND_SZValue::String
REG_DWORD, REG_QWORDValue::Int
REG_MULTI_SZValue::List of Value::String

write

rust
registry::write(key: string, name: string, value: Value, kind: string) -> Result[unit, string]

Writes a value. kind selects the registry type and must match the shape of value: sz and expand_sz take a string, dword and qword take an int, and multi_sz takes a list of strings.

delete_value

rust
registry::delete_value(key: string, name: string) -> Result[unit, string]

Deletes one value from a key.

create_key and delete_key

rust
registry::create_key(key: string) -> Result[unit, string]
registry::delete_key(key: string) -> Result[unit, string]

create_key creates a key and any missing parents. delete_key deletes a key and its whole subtree.

key_exists

rust
registry::key_exists(key: string) -> Result[bool, string]

Whether a key exists.

rust
use registry
use value

fn check(props: Value) -> Result[CheckResult, string] {
    let key = "HKLM\\Software\\Vendor\\App"
    match registry::read(key, "Telemetry")? {
        Some(v) => if v.as_int() == Some(0) { Ok(CheckResult::AlreadyConfigured) } else { Ok(CheckResult::NotConfigured) },
        None => Ok(CheckResult::NotConfigured),
    }
}