{"id":733,"url":"https://github.com/CatalystCode/windows-registry-node","last_synced_at":"2025-07-30T19:32:08.081Z","repository":{"id":57397865,"uuid":"45553630","full_name":"CatalystCode/windows-registry-node","owner":"CatalystCode","description":"Read and Write to the Windows registry in-process from Node.js. Easily set application file associations and other goodies.","archived":false,"fork":false,"pushed_at":"2019-12-10T10:44:26.000Z","size":518,"stargazers_count":116,"open_issues_count":23,"forks_count":43,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-28T19:02:04.824Z","etag":null,"topics":["npm-module","windows-registry"],"latest_commit_sha":null,"homepage":"","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/CatalystCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-11-04T16:56:43.000Z","updated_at":"2024-10-27T18:50:47.000Z","dependencies_parsed_at":"2022-09-04T13:22:26.740Z","dependency_job_id":null,"html_url":"https://github.com/CatalystCode/windows-registry-node","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fwindows-registry-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fwindows-registry-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fwindows-registry-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatalystCode%2Fwindows-registry-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CatalystCode","download_url":"https://codeload.github.com/CatalystCode/windows-registry-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228178880,"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":["npm-module","windows-registry"],"created_at":"2024-01-05T20:15:30.042Z","updated_at":"2024-12-04T19:31:54.087Z","avatar_url":"https://github.com/CatalystCode.png","language":"JavaScript","readme":"# windows-registry-node\n\n[![Build status](https://ci.appveyor.com/api/projects/status/ot69wbkyrcv7ig3p/branch/master?svg=true)](https://ci.appveyor.com/project/sedouard/windows-registry-node/branch/master)\n\nRead and Write to the Windows registry in-process from Node.js. Easily set application file associations and launch processes as an Administrator.\n\n## Install\n\nThis library interacts with native Windows APIs. To add this module to your Node application, install the package:\n\n```\nnpm install windows-registry\n\n```\n\nTo install node modules that require compilation on Windows, make sure you have installed the [necessary build tools](https://github.com/nodejs/node-gyp#installation). Specifically, we need `npm install -g node-gyp`, a cross-platform cli written in Node.js for native addon modules for Node.js. \n\nTo install `node-gyp`, install [python v2.7.3](http://www.python.org/download/releases/2.7.3#download) and [Visual Studio 2013 build tools](http://www.microsoft.com/en-gb/download/details.aspx?id=44914). You do not need to install the full Visual Studio, only the build tools are required. Once the build tools are installed, you should be able to do `npm install -g node-gyp`. \n\n## Creating File Associations\n\nTo create a file association, you can call the `fileAssociation.associateExeForFile` API, which will make windows assign a default program for an arbitrary file extension:\n\n```js\nvar utils = require('windows-registry').utils;\nutils.associateExeForFile('myTestHandler', 'A test handler for unit tests', 'C:\\\\path\\\\to\\\\icon', 'C:\\\\Program Files\\\\nodejs\\\\node.exe %1', '.zzz');\n\n```\nAfter running the code above, you will see files with the extension of `.zzz` will be automatically associated with the Node program and their file icon will be changed to the Node file icon.\n\n!['GIF showing file association'](https://github.com/CatalystCode/windows-registry-node/blob/readmeblob/fileassoc.jpg)\n\n## Reading and Writing to the Windows Registry\n\nThis library implements only a few of the basic registry commands, which allow you to do basic CRUD \noperations for keys in the registry.\n\n### Opening a Registry Key\n\nRegistry keys can be opened by either opening a predefined registry key defined in the [windef](lib/windef.js) module:\n\n```js\nvar Key = require('windows-registry').Key;\nvar key = new Key(windef.HKEY.HKEY_CLASSES_ROOT, '.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);\n\n```\n\nOr you can open a sub key from an already opened key:\n\n```js\nvar Key = require('windows-registry').Key;\nvar key = new Key(windef.HKEY.HKEY_CLASSES_ROOT, '', windef.KEY_ACCESS.KEY_ALL_ACCESS);\nvar key2 = key.openSubKey('.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);\n\n```\n\nAnd don't forget to close your key when you're done. Otherwise, you will leak native resources:\n\n```js\nkey.close();\n\n```\n\n### Creating a Key\n\nCreating a key just requires that you have a [Key](lib/key.js) object by either using the [predefined keys](https://github.com/CatalystCode/windows-registry-node/blob/master/lib/windef.js#L27) within the `windef.HKEY` or opening a subkey from an existing key.\n\n```js\nvar Key = require('windows-registry').Key;\n// predefined key\nvar key = new Key(windef.HKEY.HKEY_CLASSES_ROOT, '', windef.KEY_ACCESS.KEY_ALL_ACCESS);\nvar createdKey = key.createSubKey('\\test_key_name', windef.KEY_ACCESS.KEY_ALL_ACCESS);\n\n```\n\n### Deleting a Key\nTo delete a key just call the `Key.deleteKey()` function.\n\n```js\ncreatedKey.deleteKey();\n\n```\n\n### Writing a Value to a Key\n\nTo write a value, you will again need a [Key](lib/key.js) object and just need to call the `Key.setValue` function:\n\n```js\nvar Key = require('windows-registry').Key,\n\twindef = require('windows-registry').windef;\n\nvar key = new Key(windef.HKEY.HKEY_CLASSES_ROOT, '.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);\nkey.setValue('test_value_name', windef.REG_VALUE_TYPE.REG_SZ, 'test_value');\n\n``` \n\n### Get a Value From a Key\n\nTo get a value from a key, just call `Key.getValue`:\n\n```js\nvar value = key.getValue('test_value_name');\n```\n\nThe return value depends on the type of the key (REG_SZ for example will give you a string).\n\n## Launching a Process as an Admin\n\nTo launch a process as an Administrator, you can call the `utils.elevate` API, which will launch a process as an Administrator causing the UAC (User Account Control) elevation prompt to appear if required. This is similar to the Windows Explorer command \"Run as administrator\".  Pass in `FILEPATH` to the process you want to elevate. Pass in any`PARAMETERS` to run with the process. Since this is an asynchronous call, pass in a callback to handle user's selection.\n\n```js\nvar utils = require('windows-registry').utils;\nutils.elevate('C:\\\\Program Files\\\\nodejs\\\\node.exe', 'index.js', function (err, result){console.log(result);});\n\n```\nThe process you want to launch with admin access will only be launched after the callback is called and only if the user clicks Yes in the UAC prompt. Otherwise, the process will not be launched. If the user is already running as an admin, the UAC prompt will not be triggered and the process you provided will be launched as an administrator automatically.\n\n!['GIF showing launch process as an admin'](https://github.com/CatalystCode/windows-registry-node/blob/readmeblob/elevate.gif)\n\n## More Docs?\n\nMake your way over to the [tests section](test) to see how the module can be used.\n\n","funding_links":[],"categories":["JavaScript","Libraries"],"sub_categories":["Windows registry"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCatalystCode%2Fwindows-registry-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCatalystCode%2Fwindows-registry-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCatalystCode%2Fwindows-registry-node/lists"}