### Node.js Example: Registry Operations with Promises Source: https://github.com/kessler/node-regedit/blob/master/README.md Demonstrates common registry operations using the promisified API of node-regedit. This example shows how to list registry keys, create new keys, and put values into the registry. It utilizes async/await for cleaner asynchronous code. ```javascript const regedit = require('regedit').promisified async function main() { const listResult = await regedit.list('HKCU\SOFTWARE') console.log(listResult) await regedit.createKey(['HKLM\SOFTWARE\MyApp2', 'HKCU\SOFTWARE\MyApp']) await regedit.putValue({ 'HKCU\SOFTWARE\MyApp': { Company: { value: 'Moo corp', type: 'REG_SZ' } }, 'HKLM\SOFTWARE\MyApp2': { test: { value: '123', type: 'REG_SZ' } } }) } main() ``` -------------------------------- ### Install Node-Regedit Package Source: https://github.com/kessler/node-regedit/blob/master/README.md Install the node-regedit package using npm. This command downloads and installs the package and its dependencies into your project. ```bash npm install regedit ``` -------------------------------- ### Listing Registry Keys using Promises with Node-Regedit Source: https://github.com/kessler/node-regedit/blob/master/README.md Shows how to list registry keys using the promisified version of the node-regedit library. This example demonstrates error handling for asynchronous operations when accessing registry data. ```javascript try { const registryList = await regedit.promisified.list(['HKCU\SOFTWARE', 'HKLM\SOFTWARE', 'HKCU\IM_FAKE_THEREFOR_I_DONT_EXIST']) } catch (e) { console.log('Error while listing keys:', e.message) } ``` -------------------------------- ### Complete Registry CRUD Operations with Node-Regedit Source: https://context7.com/kessler/node-regedit/llms.txt Demonstrates the full lifecycle management of Windows Registry keys and values including creation, reading, updating, and deletion. This example requires the 'regedit' npm package and should be run with appropriate permissions (e.g., as Administrator) on a Windows system. It handles various registry data types and includes error handling for common registry operations. ```javascript const regedit = require('regedit').promisified; async function completeRegistryExample() { const baseKey = 'HKCU\SOFTWARE\MyCompany\MyProduct'; try { // CREATE - Create registry structure console.log('Creating registry keys...'); await regedit.createKey([ baseKey, `${baseKey}\Settings`, `${baseKey}\UserData` ]); // CREATE - Write initial values console.log('Writing registry values...'); await regedit.putValue({ [`${baseKey}\Settings`]: { 'Language': { value: 'en-US', type: 'REG_SZ' }, 'Theme': { value: 'dark', type: 'REG_SZ' }, 'AutoUpdate': { value: 1, type: 'REG_DWORD' }, 'CheckInterval': { value: 3600, type: 'REG_DWORD' } }, [`${baseKey}\UserData`]: { 'LastLogin': { value: new Date().toISOString(), type: 'REG_SZ' }, 'LoginCount': { value: 1, type: 'REG_DWORD' } } }); // READ - List all keys and values console.log('Reading registry data...'); const data = await regedit.list([ baseKey, `${baseKey}\Settings`, `${baseKey}\UserData` ]); console.log('Base key subkeys:', data[baseKey].keys); console.log('Settings:', data[`${baseKey}\Settings`].values); console.log('UserData:', data[`${baseKey}\UserData`].values); // UPDATE - Modify existing values console.log('Updating registry values...'); await regedit.putValue({ [`${baseKey}\Settings`]: { 'Theme': { value: 'light', type: 'REG_SZ' } }, [`${baseKey}\UserData`]: { 'LoginCount': { value: 2, type: 'REG_DWORD' }, 'LastLogin': { value: new Date().toISOString(), type: 'REG_SZ' } } }); // DELETE - Remove specific values console.log('Deleting specific values...'); await regedit.deleteValue(`${baseKey}\Settings\CheckInterval`); // DELETE - Clean up (remove entire key tree) console.log('Cleaning up registry keys...'); await regedit.deleteKey([ `${baseKey}\Settings`, `${baseKey}\UserData`, baseKey ]); console.log('Registry operations completed successfully'); } catch (err) { console.error('Registry operation failed:', err.message); // Handle specific error types if (err.code === 5 || err.message === 'access is denied') { console.error('Try running as Administrator'); } else if (err.code === 2) { console.error('Registry path does not exist'); } } } completeRegistryExample(); ``` -------------------------------- ### Node-Regedit API: List Registry Keys (Callback) Source: https://github.com/kessler/node-regedit/blob/master/README.md Example of using the callback-based API to list the direct content of one or more registry keys. It demonstrates how to query multiple keys simultaneously and process the results asynchronously. ```javascript regedit.list(['HKCU\SOFTWARE', 'HKLM\SOFTWARE', 'HKCU\IM_FAKE_THEREFOR_I_DONT_EXIST'], function(err, result) { ... }) ``` -------------------------------- ### Create Registry Keys with Promises Source: https://context7.com/kessler/node-regedit/llms.txt Demonstrates creating new registry keys using the promisified API. It shows how to create a single key or multiple keys in a batch. Parent keys are created automatically if they do not exist. Includes error handling for permission issues. ```javascript const regedit = require('regedit').promisified; async function createRegistryKeys() { try { // Create a single key await regedit.createKey('HKCU\SOFTWARE\MyApplication'); console.log('Key created successfully'); // Create multiple keys at once await regedit.createKey([ 'HKCU\SOFTWARE\MyApplication\Settings', 'HKCU\SOFTWARE\MyApplication\Cache', 'HKCU\SOFTWARE\MyApplication\Logs' ]); console.log('Multiple keys created successfully'); } catch (err) { if (err.message === 'access is denied') { console.error('Insufficient permissions to create registry key'); } else { console.error('Failed to create key:', err.message); } } } createRegistryKeys(); ``` -------------------------------- ### List Registry Keys Using Streaming Interface Source: https://context7.com/kessler/node-regedit/llms.txt Shows how to use the streaming interface for listing registry keys, which is efficient for large datasets as it processes entries as they arrive. Includes event handlers for data, errors, and completion. ```javascript const regedit = require('regedit'); // Streaming interface for handling large amounts of registry data const keys = [ 'HKLM\SOFTWARE\Microsoft', 'HKCU\SOFTWARE\Microsoft', 'HKLM\SOFTWARE\Classes' ]; regedit.list(keys) .on('data', function(entry) { console.log('Key:', entry.key); console.log('Subkeys:', entry.data.keys); console.log('Values:', entry.data.values); console.log('---'); }) .on('error', function(err) { console.error('Stream error:', err.message); }) .on('finish', function() { console.log('Registry listing completed'); }); ``` -------------------------------- ### List Registry Keys and Values with Promises Source: https://context7.com/kessler/node-regedit/llms.txt Demonstrates how to list the content of registry keys using the promisified API. It shows how to list a single key or multiple keys in a batch operation. Handles potential errors during registry access. ```javascript const regedit = require('regedit').promisified; async function listRegistryKeys() { try { // List a single key const result = await regedit.list('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion'); console.log(result); // Output: // { // 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion': { // exists: true, // keys: ['Policies', 'Explorer', 'Run', ...], // values: { // 'ProgramFilesDir': { value: 'C:\\Program Files', type: 'REG_SZ' }, // 'CommonFilesDir': { value: 'C:\\Program Files\\Common Files', type: 'REG_SZ' } // } // } // } // List multiple keys at once (batch operation) const multiResult = await regedit.list([ 'HKCU\SOFTWARE', 'HKLM\SOFTWARE', 'HKCU\NonExistentKey' ]); // Non-existent keys return exists: false console.log(multiResult['HKCU\NonExistentKey']); // Output: { exists: false, keys: [], values: {} } } catch (err) { console.error('Registry operation failed:', err.message); } } listRegistryKeys(); ``` -------------------------------- ### Callback API Usage for Registry Operations (JavaScript) Source: https://context7.com/kessler/node-regedit/llms.txt Illustrates the usage of the original callback-based API for performing registry operations such as listing keys, creating keys, and putting values. This is useful in environments where async/await is not preferred or available. ```javascript const regedit = require('regedit'); // List with callback regedit.list(['HKCU\SOFTWARE', 'HKLM\SOFTWARE'], function(err, result) { if (err) { console.error('Error:', err.message); return; } console.log('HKCU SOFTWARE keys:', result['HKCU\SOFTWARE'].keys); console.log('HKLM SOFTWARE keys:', result['HKLM\SOFTWARE'].keys); }); // Create key with callback regedit.createKey('HKCU\SOFTWARE\MyApp', function(err) { if (err) { console.error('Failed to create key:', err.message); return; } // Put value with callback (nested for sequential operation) regedit.putValue({ 'HKCU\SOFTWARE\MyApp': { 'Version': { value: '1.0.0', type: 'REG_SZ' } } }, function(err) { if (err) { console.error('Failed to put value:', err.message); return; } console.log('Application registered successfully'); }); }); ``` -------------------------------- ### Access Architecture-Specific Registry Views (JavaScript) Source: https://context7.com/kessler/node-regedit/llms.txt Demonstrates how to access 32-bit and 64-bit registry views on 64-bit Windows systems using the promisified API. It covers listing keys, creating keys, and writing values for specific architectures, as well as auto-detection. ```javascript const regedit = require('regedit').promisified; async function architectureSpecificAccess() { try { // Access 32-bit registry view (WOW6432Node on 64-bit systems) const result32 = await regedit.arch.list32('HKLM\SOFTWARE\Microsoft'); console.log('32-bit registry view:', result32); // Access 64-bit registry view const result64 = await regedit.arch.list64('HKLM\SOFTWARE\Microsoft'); console.log('64-bit registry view:', result64); // Auto-detect system architecture const resultAuto = await regedit.arch.list('HKLM\SOFTWARE\Microsoft'); console.log('System architecture view:', resultAuto); // Architecture-specific key creation await regedit.arch.createKey32('HKCU\SOFTWARE\MyApp32'); await regedit.arch.createKey64('HKCU\SOFTWARE\MyApp64'); // Architecture-specific value writing await regedit.arch.putValue32({ 'HKCU\SOFTWARE\MyApp32': { 'Architecture': { value: '32-bit', type: 'REG_SZ' } } }); await regedit.arch.putValue64({ 'HKCU\SOFTWARE\MyApp64': { 'Architecture': { value: '64-bit', type: 'REG_SZ' } } }); } catch (err) { console.error('Architecture-specific operation failed:', err.message); } } architectureSpecificAccess(); ``` -------------------------------- ### Node-Regedit API: Promise vs Callback Initialization Source: https://github.com/kessler/node-regedit/blob/master/README.md Shows how to require the node-regedit module to access either its original callback-based API or its promise-based API. This allows developers to choose their preferred asynchronous programming style. ```javascript // callback api const regedit = require('regedit') // promise api const promisifiedRegedit = require('regedit').promisified ``` -------------------------------- ### regedit.createKey Source: https://github.com/kessler/node-regedit/blob/master/README.md Creates one or more keys in the registry. ```APIDOC ## POST /regedit/createKey ### Description Creates one or more keys in the Windows registry. ### Method POST ### Endpoint /regedit/createKey ### Parameters #### Request Body - **keys** (String|Array) - Required - The registry key path(s) to create. ### Request Example ```javascript regedit.createKey(['HKCU\Software\MyNewApp', 'HKLM\Software\AnotherApp']) ``` ### Response #### Success Response (200) - **message** (String) - Confirmation message indicating the keys were created. ``` -------------------------------- ### regedit.arch.list Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry keys, automatically selecting the system's native architecture. Supports both callback and streaming interfaces. ```APIDOC ## GET /regedit/arch/list ### Description Retrieves registry keys, automatically selecting the system's native architecture (defaults to 64-bit on 64-bit systems, 32-bit on 32-bit systems). Supports both callback and streaming interfaces. ### Method GET ### Endpoint /regedit/arch/list ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to list. - **callback** (Function) - Optional - A callback function to handle the results (for non-streaming usage). ### Request Example (Streaming) ```javascript regedit.arch.list(['HKCU\Software']) .on('data', function(entry) { console.log(entry); }) .on('finish', function () { console.log('Finished'); }) ``` ### Response #### Success Response (200) - **data** (Object) - Contains registry key information, similar to `regedit.list`. ``` -------------------------------- ### Electron Integration for Registry Access (JavaScript) Source: https://context7.com/kessler/node-regedit/llms.txt Shows how to configure the node-regedit library for use within Electron applications. This involves setting a custom location for VBScript files outside the ASAR archive to ensure proper functionality. ```javascript const regedit = require('regedit'); const path = require('path'); const electron = require('electron'); // Set custom VBS location for Electron (outside ASAR) const vbsDirectory = path.join( path.dirname(electron.remote.app.getPath('exe')), './resources/regedit-vbs' ); const result = regedit.setExternalVBSLocation(vbsDirectory); if (result === 'Folder found and set') { console.log('VBS location configured successfully'); } else { console.error('VBS folder not found at:', vbsDirectory); } // Now use regedit normally const promisified = regedit.promisified; async function electronRegistryExample() { try { await promisified.createKey('HKCU\SOFTWARE\MyElectronApp'); await promisified.putValue({ 'HKCU\SOFTWARE\MyElectronApp': { 'InstallPath': { value: electron.remote.app.getPath('exe'), type: 'REG_SZ' }, 'Version': { value: electron.remote.app.getVersion(), type: 'REG_SZ' } } }); console.log('Electron app registered in Windows Registry'); } catch (err) { console.error('Registry operation failed:', err.message); } } electronRegistryExample(); ``` -------------------------------- ### List Registry Keys with System Architecture (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Automatically selects the appropriate registry architecture (32-bit or 64-bit) based on the system. This function behaves like the standard `regedit.list` but ensures compatibility with the system's native architecture. ```javascript regedit.arch.list(['HKCU\SOFTWARE'], callback) ``` -------------------------------- ### List Registry Keys with 64-bit Architecture (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Forces the registry read operation to use the 64-bit architecture. This is an alternative to the standard `regedit.list` function when specific architecture targeting is required. ```javascript regedit.arch.list64(['HKCU\SOFTWARE'], callback) ``` -------------------------------- ### List Registry Keys with 32-bit Architecture (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Forces the registry read operation to use the 32-bit architecture. This is an alternative to the standard `regedit.list` function when specific architecture targeting is required. ```javascript regedit.arch.list32(['HKCU\SOFTWARE'], callback) ``` -------------------------------- ### regedit.arch.list64 Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry keys, forcing a 64-bit architecture. Supports both callback and streaming interfaces. ```APIDOC ## GET /regedit/arch/list64 ### Description Retrieves registry keys, specifically targeting a 64-bit registry view. This function is analogous to `regedit.list` but ensures the operation is performed on the 64-bit registry hive. ### Method GET ### Endpoint /regedit/arch/list64 ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to list. - **callback** (Function) - Optional - A callback function to handle the results (for non-streaming usage). ### Request Example (Streaming) ```javascript regedit.arch.list64(['HKLM\SOFTWARE']) .on('data', function(entry) { console.log(entry); }) .on('finish', function () { console.log('Finished'); }) ``` ### Response #### Success Response (200) - **data** (Object) - Contains registry key information, similar to `regedit.list`. ``` -------------------------------- ### List Unexpanded Registry Values with Node.js Source: https://context7.com/kessler/node-regedit/llms.txt Retrieves registry values without expanding embedded environment variables, using the node-regedit library. This is useful for obtaining raw values that contain variables like %USERPROFILE%. The function returns an array of objects, each containing the path, existence status, and the unexpanded value. ```javascript const regedit = require('regedit').promisified; async function listUnexpandedValues() { try { const result = await regedit.listUnexpandedValues( 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData' ); console.log(result); // Output: // [{ // path: 'HKCU\Software\...\AppData', // exists: true, // value: '%USERPROFILE%\AppData\Roaming' // Not expanded! // }] // Compare with regular list which expands variables const expanded = await regedit.list( 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' ); // values.AppData.value would be 'C:\Users\Username\AppData\Roaming' } catch (err) { console.error('Failed to list unexpanded values:', err.message); } } listUnexpandedValues(); ``` -------------------------------- ### regedit.arch.list32 Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry keys, forcing a 32-bit architecture. Supports both callback and streaming interfaces. ```APIDOC ## GET /regedit/arch/list32 ### Description Retrieves registry keys, specifically targeting a 32-bit registry view. This function is analogous to `regedit.list` but ensures the operation is performed on the 32-bit registry hive. ### Method GET ### Endpoint /regedit/arch/list32 ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to list. - **callback** (Function) - Optional - A callback function to handle the results (for non-streaming usage). ### Request Example (Streaming) ```javascript regedit.arch.list32(['HKCU\SOFTWARE']) .on('data', function(entry) { console.log(entry); }) .on('finish', function () { console.log('Finished'); }) ``` ### Response #### Success Response (200) - **data** (Object) - Contains registry key information, similar to `regedit.list`. ``` -------------------------------- ### regedit.list - Streaming Interface Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry keys and their data via a streaming interface. This is useful for handling large amounts of data and overcoming command-line argument limitations. ```APIDOC ## GET /regedit/list (Streaming) ### Description Exposes a streaming interface for retrieving registry keys and their data. This is particularly useful for large datasets and avoids command-line argument limitations. ### Method GET ### Endpoint /regedit/list ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to list. ### Request Example ```javascript regedit.list(['HKCU\SOFTWARE', 'HKLM\SOFTWARE']) .on('data', function(entry) { console.log(entry.key) console.log(entry.data) }) .on('finish', function () { console.log('list operation finished') }) ``` ### Response #### Success Response (200) - **data** (Object) - An object containing 'keys' (direct sub-keys) and 'values' (direct child values) for each requested registry path. #### Response Example ```json { "key": "HKCU\SOFTWARE", "data": { "keys": [ "Google", "Microsoft", ... ], "values": { "valueName": { "value": "123", "type": "REG_SZ" } } } } ``` ``` -------------------------------- ### Write Registry Values with Node.js Source: https://context7.com/kessler/node-regedit/llms.txt Writes one or more values to the Windows registry using the node-regedit library. It supports various standard registry value types including REG_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY, and REG_MULTI_SZ. The function first creates the necessary key if it doesn't exist and then proceeds to write the specified values. ```javascript const regedit = require('regedit').promisified; async function writeRegistryValues() { try { // First create the key await regedit.createKey('HKCU\SOFTWARE\MyApplication\Settings'); // Write multiple values of different types await regedit.putValue({ 'HKCU\SOFTWARE\MyApplication\Settings': { // String value (REG_SZ) 'AppName': { value: 'My Application', type: 'REG_SZ' }, // Expandable string with environment variables (REG_EXPAND_SZ) 'LogPath': { value: '%USERPROFILE%\Logs\myapp.log', type: 'REG_EXPAND_SZ' }, // Integer value (REG_DWORD) 'MaxRetries': { value: 5, type: 'REG_DWORD' }, // Large integer value (REG_QWORD) 'MaxFileSize': { value: 1073741824, type: 'REG_QWORD' }, // Binary data (REG_BINARY) - array of bytes 'EncryptionKey': { value: [0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0], type: 'REG_BINARY' }, // Multi-string array (REG_MULTI_SZ) 'AllowedExtensions': { value: ['.txt', '.log', '.json', '.xml'], type: 'REG_MULTI_SZ' } } }); console.log('Registry values written successfully'); // Write default value for a key await regedit.putValue({ 'HKCU\SOFTWARE\MyApplication\FileTypes\.myapp': { 'DefaultValue': { value: 'MyApplication.Document', type: 'REG_DEFAULT' } } }); } catch (err) { console.error('Failed to write registry values:', err.message); } } writeRegistryValues(); ``` -------------------------------- ### Create Registry Keys (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Creates one or more keys in the Windows registry. This operation modifies the registry and the keys array provided as input. ```javascript regedit.createKey(['HKCU\Software\NewKey'], callback) ``` -------------------------------- ### List Registry Keys with Streaming Interface (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry keys and their data using a streaming interface, suitable for large amounts of data. This method mutates the keys array and is useful for overcoming command-line argument limitations when fetching many keys. ```javascript regedit.list(['HKCU\SOFTWARE', 'HKLM\SOFTWARE']) .on('data', function(entry) { console.log(entry.key) console.log(entry.data) }) .on('finish', function () { console.log('list operation finished') }) ``` -------------------------------- ### Setting Default Registry Values with Node-Regedit Source: https://github.com/kessler/node-regedit/blob/master/README.md Demonstrates how to set default values in the Windows registry using the node-regedit library. It highlights the requirement to use the 'REG_DEFAULT' type for default values and that the value name is insignificant. The only legal type for a default value is 'REG_SZ'. ```javascript var values = { 'HKCU\Software\MySoftware': { 'someNameIDontCareAbout': { value: 'Must be a string', type: 'REG_DEFAULT' }, 'myValue2': { value: 'aString', type: 'REG_SZ' } } } regedit.putValue(values, function (err) { }) ``` -------------------------------- ### Node-Regedit API: Accessing Default Registry Value Source: https://github.com/kessler/node-regedit/blob/master/README.md Illustrates how to access the default value of a registry key using the node-regedit module. Due to how default values are represented (empty string name), accessing them requires specific handling. ```javascript regedit.list('path\to\default\value', function (err, result) { var defaultValue = result['path\to\default\value'].values[''].value }) ``` -------------------------------- ### regedit.deleteKey Source: https://github.com/kessler/node-regedit/blob/master/README.md Deletes one or more keys from the registry. ```APIDOC ## DELETE /regedit/deleteKey ### Description Deletes one or more keys from the Windows registry. ### Method DELETE ### Endpoint /regedit/deleteKey ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to delete. ### Request Example ```javascript regedit.deleteKey(['HKCU\Software\MyOldApp', 'HKLM\Software\TempApp']) ``` ### Response #### Success Response (200) - **message** (String) - Confirmation message indicating the keys were deleted. ``` -------------------------------- ### regedit.listUnexpandedValues Source: https://github.com/kessler/node-regedit/blob/master/README.md Lists registry values without expanding environment variables. Uses a different underlying mechanism than `regedit.list` and supports streaming. ```APIDOC ## GET /regedit/listUnexpandedValues ### Description Lists the values of specified registry keys without expanding any embedded environment variables. This API uses a `RegRead` method via a `wshell` object, differing from the `StdRegServ` basis of other methods. ### Method GET ### Endpoint /regedit/listUnexpandedValues ### Parameters #### Query Parameters - **keys** (String|Array) - Required - The registry key path(s) to list values from. ### Request Example ```javascript const res = await regedit.listUnexpandedValues('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData') console.log(JSON.stringify(res, null, '\t')) ``` ### Response #### Success Response (200) - **Array** - An array of objects, each containing `path`, `exists` (boolean), and `value`. #### Response Example ```json [ { "path": "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData", "exists": true, "value": "%USERPROFILE%\AppData\Roaming" } ] ``` ``` -------------------------------- ### Put Registry Values (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Writes one or more values to the Windows registry. The input is an object structured similarly to the output of `regedit.list()`, supporting various data types like REG_SZ, REG_DWORD, REG_MULTI_SZ, and REG_BINARY. ```javascript var valuesToPut = { 'HKCU\Software\MySoftware': { 'myValue1': { value: [1,2,3], type: 'REG_BINARY' }, 'myValue2': { value: 'aString', type: 'REG_SZ' } }, 'HKCU\Software\MySoftware\foo': { 'myValue3': { value: ['a', 'b', 'c'], type: 'REG_MULTI_SZ' } } } regedit.putValue(valuesToPut, function(err) { }) ``` -------------------------------- ### Electron Configuration for Node-Regedit Source: https://github.com/kessler/node-regedit/blob/master/README.md Configures node-regedit to use an external directory for its .wsf (Windows Script Files) when used within an Electron application. This is necessary to bypass ASAR packaging limitations, allowing the script files to be accessed at runtime. ```javascript // Assuming the files lie in /resources/my-location const vbsDirectory = path.join(path.dirname(electron.remote.app.getPath('exe')), './resources/my-location'); regedit.setExternalVBSLocation(vbsDirectory); ``` -------------------------------- ### regedit.putValue Source: https://github.com/kessler/node-regedit/blob/master/README.md Writes one or more values to the registry. Supports various data types. ```APIDOC ## PUT /regedit/putValue ### Description Writes one or more values to the Windows registry. The structure of the input object mirrors the output of `regedit.list`. ### Method PUT ### Endpoint /regedit/putValue ### Parameters #### Request Body - **values** (Object) - Required - An object defining the keys and values to write. The structure should be: ``` { "RegistryKeyPath": { "ValueName1": { "value": "data", "type": "REG_SZ" }, "ValueName2": { "value": 123, "type": "REG_DWORD" }, ... } } ``` Supported value types include: REG_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ, REG_BINARY, REG_DEFAULT. ### Request Example ```javascript var valuesToPut = { 'HKCU\Software\MySoftware': { 'myValue1': { value: [1,2,3], type: 'REG_BINARY' }, 'myValue2': { value: 'aString', type: 'REG_SZ' } }, 'HKCU\Software\MySoftware\foo': { 'myValue3': { value: ['a', 'b', 'c'], type: 'REG_MULTI_SZ' } } } regedit.putValue(valuesToPut, function(err) { // Handle completion or error }) ``` ### Response #### Success Response (200) - **message** (String) - Confirmation message indicating the values were written. ``` -------------------------------- ### Delete Registry Keys with Node.js Source: https://context7.com/kessler/node-regedit/llms.txt Removes registry keys and all their subkeys and values using the node-regedit library. This function can delete a single key or multiple keys simultaneously by passing their paths as strings or an array of strings. Error handling is included for cases like insufficient permissions. ```javascript const regedit = require('regedit').promisified; async function deleteRegistryKeys() { try { // Delete a single key await regedit.deleteKey('HKCU\SOFTWARE\MyApplication\Cache'); console.log('Key deleted successfully'); // Delete multiple keys at once await regedit.deleteKey([ 'HKCU\SOFTWARE\MyApplication\Settings', 'HKCU\SOFTWARE\MyApplication\Logs' ]); console.log('Multiple keys deleted'); } catch (err) { if (err.message === 'access is denied') { console.error('Insufficient permissions to delete registry key'); } else { console.error('Failed to delete key:', err.message); } } } deleteRegistryKeys(); ``` -------------------------------- ### List Unexpanded Registry Values (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Retrieves registry values without expanding embedded environment variables. This API uses a `wshell` object's `RegRead` method and is useful for specific scenarios detailed in issue #40. It supports both callback and streaming interfaces. ```javascript const regedit = require('./index').promisified async function main() { const res = await regedit.listUnexpandedValues('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData') console.log(JSON.stringify(res, null, '\t')) } main() ``` -------------------------------- ### Delete Registry Values with Node.js Source: https://context7.com/kessler/node-regedit/llms.txt Removes specific values from registry keys without deleting the keys themselves, using the node-regedit library. This function allows for the deletion of a single value by specifying its full path, including the value name, or multiple values at once by providing an array of paths. ```javascript const regedit = require('regedit').promisified; async function deleteRegistryValues() { try { // Delete a single value (specify full path including value name) await regedit.deleteValue('HKCU\SOFTWARE\MyApplication\Settings\MaxRetries'); console.log('Value deleted successfully'); // Delete multiple values at once await regedit.deleteValue([ 'HKCU\SOFTWARE\MyApplication\Settings\LogPath', 'HKCU\SOFTWARE\MyApplication\Settings\MaxFileSize' ]); console.log('Multiple values deleted'); } catch (err) { console.error('Failed to delete value:', err.message); } } deleteRegistryValues(); ``` -------------------------------- ### Delete Registry Keys (JavaScript) Source: https://github.com/kessler/node-regedit/blob/master/README.md Deletes one or more keys from the Windows registry. This operation modifies the registry and the keys array provided as input. ```javascript regedit.deleteKey(['HKCU\Software\KeyToDelete'], callback) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.