Hives are the main sections of the registry and all begin with the word HKEY. - HKEY_LOCAL_MACHINE - HKEY_CURRENT_USER - HKEY_USER
Keys are the folders in the registry. Keys can have many nested subkeys. Keys can have a value assigned to them under the (Default)
Values/Entries are name/data pairs. There can be many values in a key. The (Default) value corresponds to the Key, the rest are their own value pairs.
depends: |
|
---|
salt.modules.reg.
Registry
¶Delay usage until this module is used
salt.modules.reg.
broadcast_change
()¶Refresh the windows environment.
Returns (bool): True if successful, otherwise False
CLI Example:
salt '*' reg.broadcast_change
salt.modules.reg.
delete_key_recursive
(hive, key, use_32bit_registry=False)¶New in version 2015.5.4.
Delete a registry key to include all subkeys.
Parameters: |
|
---|---|
Returns: | A dictionary listing the keys that deleted successfully as well as those that failed to delete. |
Return type: |
The following example will remove salt
and all its subkeys from the
SOFTWARE
key in HKEY_LOCAL_MACHINE
:
CLI Example:
salt '*' reg.delete_key_recursive HKLM SOFTWARE\salt
salt.modules.reg.
delete_value
(hive, key, vname=None, use_32bit_registry=False)¶Delete a registry value entry or the default value for a key.
Parameters: |
|
---|---|
Returns: | Returns True if successful, False if not |
Return type: |
CLI Example:
salt '*' reg.delete_value HKEY_CURRENT_USER 'SOFTWARE\Salt' 'version'
salt.modules.reg.
list_keys
(hive, key=None, use_32bit_registry=False)¶Enumerates the subkeys in a registry key or hive.
Parameters: |
|
---|---|
Returns: | A list of keys/subkeys under the hive or key. |
Return type: |
CLI Example:
salt '*' reg.list_keys HKLM 'SOFTWARE'
salt.modules.reg.
list_values
(hive, key=None, use_32bit_registry=False, include_default=True)¶Enumerates the values in a registry key or hive.
Parameters: |
|
---|---|
Returns: | A list of values under the hive or key. |
Return type: |
CLI Example:
salt '*' reg.list_values HKLM 'SYSTEM\CurrentControlSet\Services\Tcpip'
salt.modules.reg.
read_value
(hive, key, vname=None, use_32bit_registry=False)¶Reads a registry value entry or the default value for a key.
Parameters: |
|
---|---|
Returns: | A dictionary containing the passed settings as well as the value_data if successful. If unsuccessful, sets success to False. |
Return type: |
If vname is not passed:
CLI Example:
salt '*' reg.read_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version'
salt.modules.reg.
set_value
(hive, key, vname=None, vdata=None, vtype=u'REG_SZ', use_32bit_registry=False, volatile=False)¶Sets a registry value entry or the default value for a key.
Parameters: |
|
---|---|
Returns: | Returns True if successful, False if not |
Return type: |
CLI Example:
salt '*' reg.set_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version' '2015.5.2'
This function is strict about the type of vdata. For instance the the next example will fail because vtype has a value of REG_SZ and vdata has a type of int (as opposed to str as expected).
CLI Example:
salt '*' reg.set_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version' '2015.5.2' \
vtype=REG_SZ vdata=0
However, this next example where vdata is properly quoted should succeed.
CLI Example:
salt '*' reg.set_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version' '2015.5.2' \
vtype=REG_SZ vdata="'0'"
An example of using vtype REG_BINARY is as follows:
CLI Example:
salt '*' reg.set_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version' '2015.5.2' \
vtype=REG_BINARY vdata='!!binary d2hhdCdzIHRoZSBwb2ludA=='
An example of using vtype REG_LIST is as follows:
CLI Example:
salt '*' reg.set_value HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version' '2015.5.2' \
vtype=REG_LIST vdata='[a,b,c]'