Previous Topic: regGetKeyValues--Get Registry Key Value Information (Function)Next Topic: regGetVal--Get Registry Value (Function)


regGetSubKey--Retrieve Sub Keys of a Registry Key (Function)

The regGetSubKeys function returns the subkeys of a specified registry key on the local system or a remote system in an array. By default only the direct subkeys are returned. Optionally all subkeys can be retrieved recursively.

The function has the following syntax:

regGetSubKeys(sKey, fRecurse)
sKey

Specifies the registry key

, fRecurse

Retrieves nested subkeys.

This function returns an array holding the names of the subkeys of sKey. An individual subkey name is returned as a relative path starting at sKey. The returned array can be passed regCreateSubKeys() to copy a subkey tree from one system to another.

If the function fails, it raises an exception.

Examples

Get subkeys of HKLM\Software\CA with error handling:

try {
    var arr, i, l;
    arr = regGetSubKeys("HKLM\\Software\\CA");
    l = arr.length;
    for(i=0; i < l; i++)
    {
        ? arr[i]
    }
}
catch(e) {
    ? "Failure:", e
}

Recursively get all subkeys of HKLM\Software\CA:

arr = regGetSubKeys("HKLM\\Software\\CA", true);
l = arr.length;
for(i=0; i < l; i++)
{
    ? arr[i]
}

Get subkey tree from remote system client8 and apply it to remote system client9:

arr = regGetSubKeys("client8::HKLM\\Software\\ACME", true);
regSetSubKeys("client9::HKLM\\Software\\ACME", arr);

Note: The key values must be handled separately.

See also:

regCreateKey--Create a Registry Key (Function)

regCreateSubkeys--Create Subkeys From an Array (Function)