{"id":732,"url":"https://github.com/MikeKovarik/rage-edit","last_synced_at":"2025-07-30T19:32:08.083Z","repository":{"id":47638771,"uuid":"117673839","full_name":"MikeKovarik/rage-edit","owner":"MikeKovarik","description":"🗃 Simple access to, and manipulation of, the Windows Registry. With promises. Without rage.","archived":false,"fork":false,"pushed_at":"2021-08-20T07:16:16.000Z","size":166,"stargazers_count":54,"open_issues_count":4,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-26T11:24:51.420Z","etag":null,"topics":["regedit","windows-registry"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeKovarik.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-16T11:14:08.000Z","updated_at":"2024-11-06T16:12:13.000Z","dependencies_parsed_at":"2022-09-19T05:22:01.029Z","dependency_job_id":null,"html_url":"https://github.com/MikeKovarik/rage-edit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeKovarik%2Frage-edit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeKovarik%2Frage-edit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeKovarik%2Frage-edit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeKovarik%2Frage-edit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeKovarik","download_url":"https://codeload.github.com/MikeKovarik/rage-edit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228178882,"owners_count":17881104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["regedit","windows-registry"],"created_at":"2024-01-05T20:15:30.019Z","updated_at":"2024-12-04T19:31:54.236Z","avatar_url":"https://github.com/MikeKovarik.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["Windows registry"],"readme":"# rage-edit\n\n[![NPM](https://img.shields.io/npm/v/rage-edit.svg)](https://www.npmjs.com/package/rage-edit)\n[![Dependency Status](https://david-dm.org/MikeKovarik/rage-edit.svg)](https://david-dm.org/MikeKovarik/rage-edit)\n[![devDependency Status](https://david-dm.org/MikeKovarik/rage-edit/dev-status.svg)](https://david-dm.org/MikeKovarik/rage-edit#info=devDependencies)\n[![Maintenance Status](http://img.shields.io/badge/status-maintained-brightgreen.svg)](https://github.com/MikeKovarik/rage-edit/pulse)\n[![Known Vulnerabilities](https://snyk.io/test/github/MikeKovarik/rage-edit/badge.svg)](https://snyk.io/test/github/MikeKovarik/rage-edit)\n[![Discord](https://img.shields.io/discord/419198557363634178.svg)](https://discord.gg/v2mUmeD)\n[![Gitter](https://badges.gitter.im/MikeKovarik/rage-edit.svg)](https://gitter.im/MikeKovarik/rage-edit?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f4c0ee405c46126d6325/maintainability)](https://codeclimate.com/github/MikeKovarik/rage-edit/maintainability)\n\n🗃 Simple access to, and manipulation of, the Windows Registry. With promises. Without rage.\n\n\n## Installation\n\n```js\nnpm install rage-edit\n```\n\n## Keep in mind before using\n\n\n### Structure and naming (keys \u0026 values) in the Windows Registry\n\nPlease be advised that the `key` and `value` terminology from the Windows registry might be confusing because it's different than the naming widely used in the world of JS. Windows registry is much like file system with folders and files, or XML, rather than JSON.\n\nIn JSON, `key` usually stands for name of the property that stores a `value`.\n\nIn the Windows registry, `key` is like a folder (or the path to it) that can contain multiple `value`s, which are kind of like files. `value` has a name and the data content it stores (and type of the data).\n\nSo when refering to `value`, its name is often meant rather than the data it holds.\n\nTo lessen the confusion, we're often using terms like value entry, value name, name of the value entry, etc... and path stands for the path of the key.\n\n\n### Default value (empty string)\n\nEvery windows registry key always contains a default value with the empty string `''` for name. \n\n```js\n// read default value\nawait Registry.get('HKLM\\\\SOFTWARE\\\\Overwatch', '')\n// write default value\nawait Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch', '', 'Soldiers, scientists, adventurers, oddities...')\n```\n[See *Default values* section for more](#default-values)\n\n### Case in/sensitivity\n\nKey path and value names are case insensitive, you can interchangeably read, write and delete with any combination of casing. `rage-edit` lowercases everything by default.\n\n```js\nawait Registry.get('HKCR\\\\.exe', 'Content Type') // returns the data\nawait Registry.get('hkcr\\\\.exe', 'content type') // returns the data\n```\n[See *Case sensitivity* section for more](#case-sensitivity)\n\n# API\n\n## `Registry` class\n\nOnly the `Registry` class is exported (both named and default export)\n\n```js\n// ES Modules way\nimport {Registry} from 'rage-edit'\nimport Registry from 'rage-edit'\n// CJS way\nvar {Registry} = require('rage-edit')\n```\n\nIt is modelled after ES6 `Map` class with methods like `.get()`, `.set()`, `.delete()` and a few others. Those can be used in two modes - static and instance.\n\n### Static mode\n\n```js\n// Creates Overwatch key inside HKLM\\SOFTWARE if it doesn't exist yet.\n// Also creates default value inside it (with data 'Soldiers, scientists, adventurers, oddities...')\nawait Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch', '', 'Soldiers, scientists, adventurers, oddities...')\n// Gets value of 'Scientists' from key 'HKLM\\Software\\Overwatch'\nawait Registry.get('HKLM\\\\Software\\\\Overwatch', 'Scientists')\n// Creates/rewrites value entry 'hq' with data 'Switzerland' at 'HKLM\\Software\\Overwatch'\nawait Registry.set('HKLM\\\\Software\\\\Overwatch', 'hq', 'Switzerland')\n// Creates/rewrites value 'Leader' at 'HKLM\\Software\\Overwatch\\Backwatch'\nawait Registry.set('HKLM\\\\Software\\\\Overwatch\\\\Blackwatch', 'Leader', 'Gabriel Reyes')\n// Retrieves the 'leader' value from \n// NOTE: case insensitivity\nawait Registry.get('hklm\\\\software\\\\overwatch\\\\blackwatch', 'leader')\n``` \n\n### Instance mode\n\n```js\n// Creates the instance but does not yet create the Overwatch key if it doesn't exists yet.\nvar reg = new Registry('HKLM\\\\Software\\\\Overwatch')\n// Creates default value inside the key (with data 'Soldiers, scientists, adventurers, oddities...')\nawait reg.set('', 'Soldiers, scientists, adventurers, oddities...')\n// Gets value of 'Scientists' from key 'HKLM\\Software\\Overwatch'\nawait reg.get('Scientists')\n// Creates/rewrites value entry 'hq' with data 'Switzerland' at 'HKLM\\Software\\Overwatch'\nawait reg.set('hq', 'Switzerland')\n// Creates/rewrites value 'Leader' at 'HKLM\\Software\\Overwatch\\Backwatch'\nawait reg.set('\\\\Blackwatch', 'Leader', 'Gabriel Reyes')\n// Retrieves the 'leader' value from \n// NOTE: case insensitivity\nawait reg.get('\\\\blackwatch', 'leader')\n``` \n\n\n## Static methods\n\n### `.get(path, [name])`\n\nRetrieves key from `path` or content of the `name`d value entry at the path.\n\n#### Parameters:\n- `path` to a key to retrieve or from where to retrieve the value.\n- `[name]` of the value to retrieve. Optional. Default value (empty string) is retrieved if omitted.\n\n#### Returns:\n`Promise\u003cobject\u003e`\n\n#### Example\n```js\n// Retrieves key 'HKLM\\Software\\Overwatch'.\nRegistry.get('HKLM\\\\Software\\\\Overwatch')\n// Retrieves default value from 'HKLM\\Software\\Overwatch'.\nRegistry.get('HKLM\\\\Software\\\\Overwatch', '')\n// Retrieves value 'Scientists' from 'HKLM\\Software\\Overwatch'.\nRegistry.get('HKLM\\\\Software\\\\Overwatch', 'Scientists')\n```\n\n\n### `.has(path, [name])`\n\nJust like `.get()` but returns boolean depending on existence of the key or value.\n\n#### Returns:\n`Promise\u003cbool\u003e`\n\n\n### `.delete(path, [name])`\n\nDeletes a registry key at the given `path` or deletes a `name`d value entry within this key.\n\n#### Parameters\n- `path` of the key to delete, or the key that hosts the value to delete.\n- `[name]` of the value to delete.\n\n#### Returns\n`Promise`\n\n#### Example\n```js\n// Deletes subkey 'Blackwatch' (with all of its subkeys and values) inside 'HKLM\\Software\\Overwatch'\nRegistry.delete('HKLM\\\\Software\\\\Overwatch\\\\Blackwatch')\n// Deletes value 'Scientists' from 'HKLM\\Software\\Overwatch'\nRegistry.delete('HKLM\\\\Software\\\\Overwatch', 'Scientists')\n// Deletes default value entry (empty string, can be omitted) from 'HKLM\\Software\\Overwatch'\nRegistry.delete('HKLM\\\\Software\\\\Overwatch', '')\n// Deletes the key 'HKLM\\Software\\Overwatch' and all of its subkeys and values\nRegistry.delete('HKLM\\\\Software\\\\Overwatch')\n```\n\n\n\n### `.set(path[, name[, data[, type]]])`\n\nCreates or rewrites a key or `name`d value inside a key at the given `path`.\n\nIf a key at the path doesn't exist it will be created as if `Registry.set(path)` was called beforehand.\n\nCreating new keys also creates an empty default value inside it (that's how windows registry works) as if `Registry.set(path, '', '', 'REG_SZ')` was called with it.\n\n#### Parameters\n- `path` of the key where the value should be created.\n- `[name]` of the value to create or modify. Optional. To modify the key's default value (empty string) use `''`.\n- `[data]` to store in the value entry. Optional.\n- `[type]` of the stored `data`. Optional. It is inferred from the `data` if this parameter is omitted.\n\n|JS type|Registry type|\n|-|-|\n|`String`|`REG_SZ`, `REG_EXPAND_SZ`|\n|`Number`|`REG_DWORD`|\n|`Array\u003cString\u003e`|`REG_MULTI_SZ`|\n|`Buffer`, `Uint8Array`, `ArrayBuffer`|`REG_BINARY`|\n\n#### Returns\n\n`Promise`\n\n#### Example\n\n```js\n// Creates or rewrites value entry named 'Leader' with 'Jack Morrison' data of 'REG_SZ' type that is infered from the String data.\n// inside the key 'HKLM\\Software\\Overwatch'. Also creates the key if it didn't exist\nRegistry.set('HKLM\\\\Software\\\\Overwatch', 'Leader', 'Jack Morrison')\n// Creates or rewrites value 'Scientists' with data 'Angela Ziegler\\0Winston\\0Mei-Ling Zhou' of type 'REG_MUTLI_SZ' (inferred from Array data)\nRegistry.set('HKLM\\\\Software\\\\Overwatch', 'Scientists', ['Angela Ziegler', 'Winston', 'Mei-Ling Zhou'])\n// Re/writes data of default value entry.\nRegistry.set('HKLM\\\\Software\\\\Overwatch', '', 'This is data of the default value entry')\n// Creates a new subkey 'Blackwatch' inside 'HKLM\\Software\\Overwatch' and creates default value with data 'Mysterious branch of Overwatch'\nRegistry.set('HKLM\\\\Software\\\\Overwatch\\\\Blackwatch', '', 'Mysterious branch of Overwatch')\n```\n\n\n\n## Static properties\n\n\n**`DEFAULT = ''`** String used to represent the name of the default value.\n\n**`VALUES = '$values'`** String used for naming values key in [simple mode](#simple)\n\n\n\n\n\n\n## Constructor, instance mode\n\n### `new Registry(path)`\n\n```js\nvar reg = new Registry('HKLM\\\\Software\\\\Overwatch')\nreg.get('Scientists')\nreg.set('\\\\Blackwatch', 'Leader', 'Gabriel Reyes')\n```\n\n\n\n\n## Instance methods\n\n\n### `#get([subpath][, name])`\n\nRetrieves key from the instance's path or from a given `subpath`.\nOr instead retrieves content of a value at the path if `name` is defined.\n\n#### Parameters:\n- `[subpath]` Path to a subkey where the value is stored. Optional. Defaults to `this.path`.\n- `[name]` of the value to retrieve. Optional. Default value (empty string) is retrieved if omitted.\n\n#### Returns:\n`Promise\u003cobject\u003e`\n\n#### Example\n```js\n// Creates instance of Registry, using 'HKLM\\Software\\Overwatch' path for all operations by default.\nvar reg = new Registry('HKLM\\\\Software\\\\Overwatch')\n// Retrieves key 'HKLM\\Software\\Overwatch'.\nreg.get()\n// Retrieves default value from 'HKLM\\Software\\Overwatch'.\nreg.get('')\n// Retrieves value 'Scientists' from 'HKLM\\Software\\Overwatch'.\nreg.get('Scientists')\n// Retrieves subkey 'Blackwatch' inside 'HKLM\\Software\\Overwatch'.\nreg.get('\\\\Blackwatch')\n// Retrieves default value from 'HKLM\\Software\\Overwatch\\Backwatch'\nreg.get('\\\\Blackwatch', '')\n// Retrieves value 'Leader' from 'HKLM\\Software\\Overwatch\\Backwatch'\nreg.get('\\\\Blackwatch', 'Leader')\n```\n\n\n\n### `#has([subpath][, name])`\n\nJust like `.get()` but returns boolean depending on existence of the sub/key or value.\n\n#### Returns:\n`Promise\u003cbool\u003e`\n\n\n\n### `#delete([subpath][, name])`\n\nDeletes the instance's registry key or subkey at given `subath`.\nAlternatively deletes `name`d value from the key.\n\n#### Parameters:\n- `[subpath]` Path to a subkey where the value is stored. Optional. Defaults to `this.path`.\n- `[name]` of the value to delete.\n\n#### Returns:\n`Promise`\n\n\n\n### `#set([subpath][, name[, data[, type]]])`\n\nCreates or rewrites `name`d value inside instance's path or at given `subpath` key.\nAlternatively creates subkey at `subpath` if `name` and `data` are undefined.\n\n#### Parameters\n- `[subpath]` Path of the subkey to create (or where to set value). Optional if `name` is defined. **`subpath` has to always begin with a backslash `\\` otherwise it will be mistaken as `name`**\n- `[name]` of the value to create or modify. Optional if `subpath` is defined in which case no value is created, only the subkey. To modify key's default value (empty string) use `''`.\n- `[data]` to be stored in the value entry. Optional.\n- `[type]` of the stored `data`. Optional. It is inferred from the `data` if this parameter is omitted.\n\n#### Returns:\n`Promise`\n\n#### Example\n```js\n// Creates instance of Registry, using 'HKLM\\Software\\Overwatch' path for all operations by default.\nvar reg = new Registry('HKLM\\\\Software\\\\Overwatch')\n// Creates the key (if it didn't exist)\nreg.set()\n// Creates 'disbanded' value with no data\nreg.set('disbanded')\n// Creates or rewrites value entry named 'Leader' with 'Jack Morrison' data of 'REG_SZ' type that is infered from the String data.\n// inside the key 'HKLM\\Software\\Overwatch'. Also creates the key if it didn't exist\nreg.set('Leader', 'Jack Morrison')\n// Creates or rewrites value 'Scientists' with data 'Angela Ziegler\\0Winston\\0Mei-Ling Zhou' of type 'REG_MUTLI_SZ' (inferred from Array data)\nreg.set('Scientists', ['Angela Ziegler', 'Winston', 'Mei-Ling Zhou'])\n// Re/writes data of default value entry.\nreg.set('', 'This is data of the default value entry')\n// Creates a key 'HKLM\\Software\\Overwatch\\Blackwatch' (if it didn't exist)\nreg.set('\\\\Blackwatch')\n// Creates a new subkey 'Blackwatch' inside 'HKLM\\Software\\Overwatch' and creates default value with data Mysterious branch of Overwatch'\nreg.set('\\\\Blackwatch', '', 'Mysterious branch of Overwatch')\n// Creates/rewrites value 'Leader' at 'HKLM\\Software\\Overwatch\\Backwatch'\nreg.set('\\\\Blackwatch', 'Leader', 'Gabriel Reyes')\n```\n\n\n## Instance properties\n\n**`path`** Full path of current key path.\n\n**`hive`** Short name of the current hive like `HKCU`.\n\n\n\n\n\n## Output format\n\nRetrieving data from the registry poses a complication. Format of the output cannot be as straight forward as JSONs nested structure because the registry better resembles an XML tree where each node can have both a children nodes and also attributes. A Windows registry key can host sub keys as well as value entries, both of which can have the same names leading to possible collisions.\n\nDue to that `rage-edit` offers two types of output formats. `simple` and `complex`. By default `simple` is enabled globally for all calls.\n\nIt can be set as a global default for all method calls, or specified manually in each method call in the `options` argument.\n\n```js\n// change format globally\nRegistry.format = 'complex'\n// or individually\nRegistry.get('HKCR\\\\Directory\\\\shell', {format: 'complex'}\n```\n\n\n### Simple\n\nSimple output tries to resemble JSON at much as possible while trying to avoid collisions with the names of keys and values.\n\nKey names are properties of the object. The key is represented by (stub of) another object. This is useful when calling `Registry.get()` in recursive mode.\n\nValues are stored in `$values` object of `name:data` pairs, where value name is the property, value data is the content of that property, and type is omitted.\n\n*Warning: `$values` might be still conflicting since `$` is a valid character in key paths. You can change `$values` to be whatever else by changing `Registry.VALUES`. e.g. `Registry.VALUES = '__$$NO_CONFLICT_VALUES'`*\n\nSo if your key has a subkey named `version` and also a value named `version`, you will be able to access both of them without collision with `output.version` and `output.$values.version`.\n\n```js\n// Registry.get('HKCR\\\\.jpg')\n{\n  $values: {\n    '': 'jpegfile',\n    'content type': 'image/jpeg',\n    'perceivedtype': 'image'\n  },\n  'openwithprogids': {...},\n  'persistenthandler': {...}\n}\n```\n\nThis format is optimized for nesting to allow you to do this.\n\n*Note: `.get()` calls are not recursive by default due to performance reasons. The following snippet serves as an example of how output can be nested, but the `HKLM` hive contains enormous amounts of data and thus is not recommended to be queried recursively.*\n\n```js\n// Gets default value (empty string) of HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lock Screen\\FeedManager\nvar software = await Registry.get('HKLM\\\\software', true)\nsoftware.microsoft.windows.currentversion['Lock Screen'].feedmanager.$values['']\n```\n\n### Complex\n\nOffers comprehensive output and first and foremost contains types of value entries since every value entry is represented by `{name, data, type}` object in a `values` array.\n\n```js\n// Registry.get('HKCR\\\\.jpg', {format: 'complex'})\n{\n  keys: {\n    'openwithprogids': {\n      keys: {...},\n      values: [...]\n    },\n    'persistenthandler': {\n      keys: {...},\n      values: [...]\n    }\n  },\n  values: [\n    {\n      name: '',\n      data: 'jpegfile',\n      type: 'REG_SZ'\n    }, {\n      name: 'content type',\n      data: 'image/jpeg',\n      type: 'REG_SZ'\n    }, {\n      name: 'perceivedtype',\n      data: 'image',\n      type: 'REG_SZ'\n    }\n  ]\n}\n```\n\nNesting with this format is much more verbose.\n\n```js\n// Gets default value (empty string) of HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Lock Screen\\FeedManager\nvar software = await Registry.get('HKLM\\\\software', true, {format: 'complex'})\nsoftware.keys.microsoft.keys.windows.keys.currentversion.keys['Lock Screen'].keys.feedmanager.values['']\n```\n\n\n\n# Caveats, edge cases \u0026 the weirdness of Windows registry\n\nWindows registry has its fair share of footguns that you should be aware of. Not to mention the danger of damaging keys and values that are critical for the proper operation of the OS.\n\n### Friendly reminder about HKCR, HKLM, 64b and Wow6432Nodes\n\n`HKCR` is a pointer to `HKLM\\Software\\Classes`. Use it to access all users.\n\n`HKCU` is a pointer to `HKUS\\${UserSid}` Use it to access only current user.\n\nTherefore\n\n`HKCU\\Software\\Classes` is a pointer to `HKUS\\${UserSid}\\Software\\Classes` which is another pointer to `HKUS\\${UserSid}_Classes`.\n\nBut on on 64b it points to subkey `Wow6432Nodes`, so `HKUS\\${UserSid}\\Software\\Classes` is a pointer to `HKUS\\${UserSid}_Classes\\Wow6432Node` on 64b systems.\n\nExample:\n\n|original key|pointer to|b|\n|-|-|-|\n|`HKCU\\Software\\Classes\\CLSID`|`HKUS\\${UserSid}_Classes\\CLSID`|32b|\n|`HKCU\\Software\\Classes\\CLSID`|`HKUS\\${UserSid}_Classes\\Wow6432Node\\CLSID`|64b|\n\nMore info [here](https://mintywhite.com/vista/hkcr-hkcu-hklm-hku-hkcc-registry-root-keys/) and [here](https://msdn.microsoft.com/en-gb/library/aa384253%28v=VS.85%29.aspx?f=255\u0026MSPPError=-2147217396\n)\n\n### Default values\n\n**Every key has a default value (empty string) which is represented as an empty string**. I.e. name of the value entry is empty string `''`. You might also come across it as a `(Default)` in the `regedit` program or in `reg` command.\n\n```js\n(await Registry.get(path)).$values[''] // value of the default value at given path\nawait Registry.get(path, '') // get default value from the path\nawait Registry.set(path, '', 'data of the default value') // set default value's data\n```\n\nIt is by default of type `REG_SZ`.\n\nCreation of a new key also creates default value inside it. The value's name is an empty string `''` and the data content is also an empty string.\nAs long as the default value has any data, it will act as any other value and will show up in `getValues()`.\n\n```js\nawait Registry.set(path)\nawait Registry.has(path, '') // true - default value exists in this key\nawait Registry.get(path, '') // '' - default value has data of an empty string\n(await Registry.get(path)).$values // [''] - list of values in this key, so far only the default value\n```\npractical example:\n```js\n// creates new key and default value '' of type REG_SZ\nawait Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch')\n// creates or updates default value of type REG_SZ, inside key HKLM\\SOFTWARE\\Overwatch (also creates the key if it doesn't exists) \nawait Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch', '', 'Soldiers, scientists, adventurers, oddities...')\n// creates or updates default value of type REG_EXPAND_SZ, inside key HKLM\\SOFTWARE\\Overwatch (also creates the key if it doesn't exists)\nawait Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch', '', 'Soldiers, scientists, adventurers, oddities...', 'REG_EXPAND_SZ')\n// sidenote: value name is '', value data is 'Soldiers, scientists, adventurers, oddities...')\n```\n\n**Default value cannot be deleted**. Attempting to do so (`Registry.delete(path, '')`) will not actually delete the entry, but only its data. Or rather it will set the data to some sort of `undefined` or `null` (can be seen as `(value not set)` in `regedit`), which is unique to the default value.\n\nIn this state, the default value returns `undefined` when queried with `get()` it will not be listed in `$values`, despite actually existing - `has()` always returns `true`.\n\n```js\nawait Registry.delete(path, '')\nawait Registry.has(path, '') // true - the value always exists\nawait Registry.get(path, '') // undefined - the value has no data\n(await Registry.get(path)).$value // [] - empty array\n```\n\n\n### Restricted access, administrator permissions\n\nWrite and delete operation outside `HKCU` hive (Current user) as well as reading certain hives require the app to run with administrator privileges.\n\n```js\ntry {\n  await Registry.set('HKCU\\\\SOFTWARE\\\\Overwatch')\n  console.log('Written to HKCU without admin priviledges.')\n  await Registry.set('HKLM\\\\SOFTWARE\\\\Overwatch')\n  console.log('Written to HKLM with admin priviledges.')\n} catch(err) {\n  console.log(`Couldn't write to HKLM without admin priviledges.`)\n}\n```\n\n### Error suppresion\n\n`rage-edit` deliberately suppresses error `The system was unable to find the specified registry key or value` that is thrown by the `reg` command when a non-existent value or key is queried. Instead the promise is resolve with `undefined`.\n\nAll other errors (especially `Access is denied`) are thrown as expected and the promise will be rejected.\n\n### Case sensitivity\n\n**Windows Registry is case insensitive.** That applies to key paths and value names. But there are some edge cases. `rage-edit` by default transforms all key paths and value names (*not the actual data of value entry*) to lowercase by default to prevent confusion.\n\nThis does not affect input - you can still use all-caps paths and value names with uppercased characters.\n\n```js\n// both ways work and return the same value\nawait Registry.get('HKCR\\\\.exe', 'Content Type') // returns the data\nawait Registry.get('hkcr\\\\.exe', 'content type') // returns the data\nawait Registry.get('HKCR\\\\.exe\\\\PersistentHandler') // returns the data\nawait Registry.get('HkCr\\\\.exe\\\\persistentHANDLER') // returns the data\nvar key = await Registry.get('HKCR\\\\.exe')\nkey.persistenthandler // contains the data\nkey.PersistentHandler // undefined\nkey.$values['content type'] // contains the data\nkey.$values['Content Type'] // undefined\n```\n\nThe lowercasing can be turned off\n\n```js\n// globally\nRegistry.lowercase = false\n// or per request\nvar key = await Registry.get('HKCR\\\\.exe', {lowercase: false})\nkey.$values['Content Type']\n```\n\n#### Why?\n\nUnderlying REG command doesn't distinguish between lowercase or upper case. Direct queries for a certain value with `/v` argument always mimic the case in which the key and value name are inputted and never return the true case of the value name. In this case `PERCEIVEDTYPE`, `PerceivedType` and `perceivedtype`\n\n```\nreg query HKCR\\.JPG /v PERCEIVEDTYPE\n\nHKEY_CLASSES_ROOT\\.JPG\n    PERCEIVEDTYPE    REG_SZ    image\n```\n\n```\nreg query HKCR\\.Jpg /v PerceivedType\n\nHKEY_CLASSES_ROOT\\.Jpg\n    PerceivedType    REG_SZ    image\n```\n\n```\nreg query HKCR\\.jpg /v perceivedtype\n\nHKEY_CLASSES_ROOT\\.jpg\n    perceivedtype    REG_SZ    image\n```\n\nBut omiting `/v` (value name) argument to query all contents of the key would return value entries with their true names (in this case `PerceivedType`).\n\n```\nC:\\WINDOWS\\system32\u003ereg query HKCR\\.jpg\n\nHKEY_CLASSES_ROOT\\.jpg\n    (Default)    REG_SZ    jpegfile\n    Content Type    REG_SZ    image/jpeg\n    PerceivedType    REG_SZ    image\n```\n\nThis however could cause performance issues (querying whole key when only single value is needed isn't a good idea) and the insensitive nature of Windows Registry lead `rage-edit` to deliberately lowercase all paths and value names to prevent situations like this:\n\n```js\n// rage-edit by default transforms all value names to lower case to prevent having to do this:\nvar key = await Registry.get('HKLM\\\\SOFTWARE\\\\MyApp')\nvar version = key.$values['VERSION'] || key.$values['Version'] || key.$values['version']\n```\n\n### Type infering and conversions\n\n`rage-edit` automatically picks a registry value type for you, based in the data you're storing, if you don't specify the type for yourself.\n\n```js\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 'string', 'REG_SZ')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 'string')\n\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', '123', 'REG_DWORD')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 123, 'REG_DWORD')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 123)\n\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 'one\\0two\\0three', 'REG_MULTI_SZ')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', ['one', 'two', 'three'], 'REG_MULTI_SZ')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', ['one', 'two', 'three'])\n\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', 'hello', 'REG_BINARY')\nRegistry.setValue('HKLM\\\\Some\\\\Path', 'name', Buffer.from('hello'))\n```\n\n\n### REG_DWORD and REG_QWORD\n\nWindows Registry allows storing 32b values as DWORDS and 64b values as QWORDS.\n\nJavascript Number only support 53 bit integers.\n\nDWORD values are automatically converted to and from Number by `rage-edit` automatically. \n\nQWORD values cannot be converted due to JS limitations. The `reg` command also retrieves the values in hex `Ox` notation and `rage-edit` does not change that.\n\n```js\nvar value = 1234\n\nRegistry.set('HKLM\\\\Some\\\\Path', 'DwordValue', value)\nRegistry.set('HKLM\\\\Some\\\\Path', 'QwordValue', value)\n\nRegistry.get('HKLM\\\\Some\\\\Path', 'DwordValue') // 1234\nRegistry.get('HKLM\\\\Some\\\\Path', 'QwordValue') // '0x4D2'\n```\n\n\n## Join the discussion\n\nWe're at [Discord](https://discord.gg/v2mUmeD) and [Gitter](https://gitter.im/MikeKovarik/rage-edit). Come join us to discuss features, bugs and more.\n\n## Credits\n\nMade by Mike Kovařík, Mutiny.cz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMikeKovarik%2Frage-edit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMikeKovarik%2Frage-edit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMikeKovarik%2Frage-edit/lists"}