Use these methods to manipulate the registry structure and data:
createKey(keys, [architecture], callback)
Creates a new registry key at the specified path(s). keys can be a string or an array.
deleteKey(keys, [architecture], callback)
Deletes the specified registry key(s).
deleteValue(keys, [architecture], callback)
Deletes a specific value within a key. keys should be the path to the key.
putValue(map, [architecture], callback)
Sets values in the registry. The map object follows this structure:
{
"KEY_PATH": {
"VALUE_NAME": {
"type": "REG_SZ | REG_BINARY | REG_MULTI_SZ | REG_DWORD",
"value": "actual_value"
}
}
}
Note: For REG_BINARY, the value must be an array of numbers. For REG_MULTI_SZ, the value must be an array of strings.
const regedit = require('regedit');
// Create a key
regedit.createKey('HKEY_CURRENT_USER\\Software\\MyApp', 'S', (err) => {
if (err) console.error(err);
});
// Put a value
const map = {
'HKEY_CURRENT_USER\\Software\\MyApp': {
'Version': { type: 'REG_SZ', value: '1.0.0' },
'Flags': { type: 'REG_DWORD', value: 1 }
}
};
regedit.putValue(map, 'S', (err) => {
if (err) console.error(err);
});