Manage Windows Registry keys

Use case

Windows software often stores its configuration in the Windows registry. The software and system configuration of your Windows nodes hence relies on a clear and correct registry management.

Base

Rudder offers different ways to manage the Windows registry:

  • By using the Technique Editor and dedicated generic methods

  • By using the technique Registry key edition

The technique is only a fancy overlay of the registry_entry_* generic method.

Quick recall

A Registry Key is the path containing Registry entries. On this image we can see:

  • Registry keys on the left

  • Registry entries for the Registry Key Computer\HKEY_CURRENT_USER\Environment

Regedit view

Each Registry entry is a typed key/value pair. The different supported types are described on the Microsoft Powershell documentation here.

This is the types name given by Powershell, if you try to read/access registry by another way than Powershell, the types name will most likely be different.

In Rudder we chose to keep the same types:

Type Description

String

Char string

ExpandString

Char string that can contains dynamic environment variables

MultiString

Char string with multiple lines

Dword

32 bits word

Qword

8 bytes word

Binary

Binary data

Non Char based type values must be entered via hexadecimal syntax: like 0xfff3f2f

Usage

There are two types of generic methods to handle registry keys:

  • Registry_Key_{present/absent} which handle registry keys

  • Registry_Entry_{present/absent} which handle registry entries and their associated values

To make sure a key is present/absent on the node you can use the generic methods as-is.

Rudder only supports local Windows registry at the moment and registry keys have to be relative to Computer.

  • For the key Computer\HKEY_CURRENT_USER\Environment pass HKEY_CURRENT_USER\Environment as Key parameter.

If you want to manage the value of a registry entry, you can use the associated generic method. If the associated registry key is not already existing, Rudder will not create it. In some rare case, if you really want to manage a registry entry even if it is not already existing, you can always couple the registry_entry_key_present with the registry_entry_present to enforce this behaviour.