registryvalue

Table of Contents

Prototype: registryvalue(key, valueid)

Return type: string

Description: Returns the value of valueid in the Windows registry key key.

This function applies only to Windows-based systems. The value is parsed as a string.

Arguments:

  • key: string, in the range: .*
  • valueid: string, in the range: .*

Example:

body common control
{
      bundlesequence => { "reg" };
}

bundle agent reg
{
  vars:
    windows::
      "value" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\CFEngine AS\CFEngine","value3");
    !windows::
      "value" string => "Sorry, no registry data is available";

  reports:
      "Value extracted: $(value)";

}

Output:

R: Value extracted: Sorry, no registry data is available

Notes: Currently values of type REG_SZ (string), REG_EXPAND_SZ (expandable string) and REG_DWORD (double word) are supported.