Skip to main content

1E 9.x (on-premises)

NativeServices.RegistrySetValue

Method

RegistrySetValue

Module

NativeServices

Library

Core

Action

Set a registry value.

Parameters

Hive (string): The registry hive which has to match one of the following long or short names, ignoring case:

Long Name

Short Name

HKEY_CLASSES_ROOT

HKCR

HKEY_CURRENT_CONFIG

HKCC

HKEY_CURRENT_USER

HKCU

HKEY_LOCAL_MACHINE

HKLM

Subkey (string): The registry key to look for.

Name (string): The name of the registry value to set.

ValueType (string): One of these supported types: "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY", "REG_DWORD", "REG_QWORD", "REG_MULTI_SZ".

Value (string): The actual value, always as a string.

Return values

Status (string): one of the following:

  • "Set value" if successful and the key already existed

  • "Created key and set value" if the key had to be created first

  • a registry error message.

Example

NativeServices.RegistrySetValue(Hive:"HKLM", Subkey:"software\\vendor\\test", Name:"value9", ValueType:"REG_DWORD", Value:"65535");
NativeServices.RegistrySetValue(Hive:"HKLM", Subkey:"software\\1e\\test", Name:"value10", ValueType:"REG_MULTI_SZ", Value:"line1|line2|line3");

Platforms

  • Windows

Notes

A REG_BINARY Value is a string of hex digits, e.g. "546F6D". Upper, lower or mixed case can be used.

The '|' character is used as a newline when setting REG_MULTI_SZ keys.

For setting a registry value for every user under HKU, use NativeServices.RegistrySetUserValues.