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
- Windows registry key - in the range:.*
valueid
:string
- Windows registry value-id - in the range:.*
Example:
code
body common control
{
bundlesequence => { "reg" };
}
bundle agent reg
{
vars:
windows::
"value" string => registryvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Northern.tech AS\CFEngine","value3");
!windows::
"value" string => "Sorry, no registry data is available";
reports:
"Value extracted: $(value)";
}
Output:
code
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.