All Projects → ironSource → Node Regedit

ironSource / Node Regedit

Licence: mit
Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Regedit

Catchart
Pipe something from command line to a chart in the browser
Stars: ✭ 27 (-84.83%)
Mutual labels:  npm-package, npm-module
Webcam Easy
javascript access webcam stream and take photo
Stars: ✭ 79 (-55.62%)
Mutual labels:  npm-package, npm-module
Awesome Node Utils
some useful npm packages for nodejs itself
Stars: ✭ 51 (-71.35%)
Mutual labels:  npm-package, npm-module
Npm Run All
A CLI tool to run multiple npm-scripts in parallel or sequential.
Stars: ✭ 4,496 (+2425.84%)
Mutual labels:  npm-package, npm-module
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+1009.55%)
Mutual labels:  npm-package, npm-module
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+270.22%)
Mutual labels:  npm-package, npm-module
Package.json
文件 package.json 的说明文档。
Stars: ✭ 67 (-62.36%)
Mutual labels:  npm-package, npm-module
A To Z List Of Useful Node.js Modules
Collection of most awesome node modules that will extend the capability of your node.js application.
Stars: ✭ 315 (+76.97%)
Mutual labels:  npm-package, npm-module
Event Target Shim
An implementation of WHATWG EventTarget interface, plus few extensions.
Stars: ✭ 89 (-50%)
Mutual labels:  npm-package, npm-module
Forge Node App
🛠📦🎉 Generate Node.js boilerplate with optional libraries & tools
Stars: ✭ 90 (-49.44%)
Mutual labels:  npm-package, npm-module
Cpx
A cli tool to watch and copy file globs.
Stars: ✭ 394 (+121.35%)
Mutual labels:  npm-package, npm-module
React Ckeditor
CKEditor component for React with plugin and custom event listeners support
Stars: ✭ 124 (-30.34%)
Mutual labels:  npm-package, npm-module
Chronos
📊 📊 📊 Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.
Stars: ✭ 347 (+94.94%)
Mutual labels:  npm-package, npm-module
Eslint Plugin Node
Additional ESLint's rules for Node.js
Stars: ✭ 740 (+315.73%)
Mutual labels:  npm-package, npm-module
Eslint Plugin Vue
Official ESLint plugin for Vue.js
Stars: ✭ 3,592 (+1917.98%)
Mutual labels:  npm-package, npm-module
Packagephobia
⚖️ Find the cost of adding a new dependency to your project
Stars: ✭ 1,110 (+523.6%)
Mutual labels:  npm-package, npm-module
midtrans-node
Unoffficial Midtrans Payment API Client for Node JS | Alternative for Midtrans Official Module | https://midtrans.com
Stars: ✭ 15 (-91.57%)
Mutual labels:  npm-package, npm-module
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (+43.82%)
Mutual labels:  npm-package, npm-module
Node Loadbalance
A collection of distilled load balancing engines
Stars: ✭ 79 (-55.62%)
Mutual labels:  npm-package, npm-module
Tplink Cloud Api
A node.js npm module to remotely control TP-Link smartplugs (HS100, HS110) and smartbulbs (LB100, LB110, LB120, LB130) using their cloud web service (no need to be on the same wifi/lan)
Stars: ✭ 96 (-46.07%)
Mutual labels:  npm-package, npm-module

regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host.

No pesky native code :-)

Install

NPM NPM

Example

var regedit = require('regedit')

regedit.list('HKCU\\SOFTWARE', function(err, result) {
    ...
})

regedit.putValue({
    'HKCU\\SOFTWARE\\MyApp': {
        'Company': {
            value: 'Moo corp',
            type: 'REG_SZ'
        },
        'Version': { ... }
    },
    'HKLM\\SOFTWARE\\MyApp2': { ... }
}, function(err) {
    ...
})

regedit.createKey(['HKLM\\SOFTWARE\\Moo', 'HKCU\\SOFTWARE\\Foo'], function(err) {
    ...
})

Friendly warning regarding 32bit and 64bit OS / Process

When launching a 32bit application in 64bit environment, some of your paths will be relative to wow6432node. Things might get a little unexpected if you try to find something you thought was in HKLM\Software when in fact it is located at HKLM\Software\wow6432node. To overcome this the arch methods were added.

Further reading here

A note about Electron

This software uses Windows Script Host to read and write to the registry. For that purpose, it will execute .wsf files. When packaging the app's dependencies with ASAR, node-regedit will not be able to access the windows script files, because they are bundled in a single ASAR file. Therefore it is necessary to store the .wsf files elsewhere, outside of the packaged asar file. You can set your custom location for the files with setExternalVBSLocation(location):

// Assuming the files lie in <app>/resources/my-location
const vbsDirectory = path.join(path.dirname(electron.remote.app.getPath('exe')), './resources/my-location');
regedit.setExternalVBSLocation(vbsDirectory);

Also, take a look at #60

API

Every command executes a sub process that runs vbscript code. To boost efficiency, every command supports batching.

Reading keys and values

regedit.list([String|Array], [Function])

Lists the direct content of one or more sub keys. Specify an array instead of a string to query multiple keys in the same run.

Given the command:

regedit.list(['HKCU\\SOFTWARE', 'HKLM\\SOFTWARE'], function(err, result) {
    ...
})

Result will be an object with the following structure:

{
    'HKCU\\SOFTWARE': {
        keys: [ 'Google', 'Microsoft', ... more direct sub keys ]
        values: {
            'valueName': {
                value: '123',
                type: 'REG_SZ'
            }
            ... more direct child values of HKCU\\SOFTWARE
        }
    },
    'HKLM\\SOFTWARE': {
        keys: [ 'Google', 'Microsoft', ... more direct sub keys ]
        values: {
            'valueName': {
                value: '123',
                type: 'REG_SZ'
            }
            ... more direct child values of HKLM\\SOFTWARE
        }
    }
}
Note about listing default values

In the windows registry a key may have a default value. When enumarting value names, the default value's name will be empty. This presents a minor problem when including the empty value in a set with other values since it cannot be safely named with anything but the empty string, for fear of collision with other values.

Thus, accessing the default value becomes slightly awkward:

regedit.list('path\\to\\default\\value', function (err, result) {
    var defaultValue = result['path\\to\\default\\value'].values[''].value
})

For now this is how its going to be, but in the future this will probably change, possibly in a way that will effect the whole interface.

list with callback api will be deperecated and eventually removed in future versions, take a look at the streaming interface below

regedit.list([String|Array]) - streaming interface

Same as regedit.list([String|Array], [Function]) exposes a streaming interface instead of a callback. This is useful for situations where you have a lot of data coming in and out of the list process. Eventually this will completely replace the list() with callback api

This operation will mutate the keys array

Example:

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')
})

This code output will look like this:

HKCU\\SOFTWARE
{
    keys: [ 'Google', 'Microsoft', ... more direct sub keys ]
    values: {
        'valueName': {
            value: '123',
            type: 'REG_SZ'
        }
        ... more direct child values of HKCU\\SOFTWARE
    }
}
HKLM\\SOFTWARE
{
    keys: [ 'Google', 'Microsoft', ... more direct sub keys ]
    values: {
        'valueName': {
            value: '123',
            type: 'REG_SZ'
        }
        ... more direct child values of HKLM\\SOFTWARE    
    }
}

regedit.arch.list32([String|Array], [Function])

same as regedit.list([String|Array], [Function]), only force a 32bit architecture on the registry

regedit.arch.list32([String|Array])

streaming interface, see regedit.list([String|Array])

regedit.arch.list64([String|Array], [Function])

same as list, only force a 64bit architecture on the registry

regedit.arch.list64([String|Array])

streaming interface, see regedit.list([String|Array])

regedit.arch.list([String|Array], [Function])

same as list, only force your system architecture on the registry (select automatically between list64 and list32)

regedit.arch.list([String|Array])

streaming interface, see regedit.list([String|Array])

Manipulating the registry

regedit.createKey([String|Array], [Function])

Creates one or more keys in the registry This operation will mutate the keys array

regedit.deleteKey([String|Array], [Function])

Deletes one or more keys in the registry This operation will mutate the keys array

regedit.putValue(Object, Function)

Put one or more values in the registry. The Object given to this function is almost identical to the result of regedit.list().

Here is an example:

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) {

})

Supported value types are:

  • REG_SZ, REG_EXPAND_SZ: a string basically
  • REG_DWORD, REG_QWORD: should use javascript numbers
  • REG_MULTI_SZ: an array of strings
  • REG_BINARY: an array of numbers (representing bytes)
  • REG_DEFAULT: see note about default values below
Note about setting default values

When including a default value in a putValue operation, one must use the REG_DEFAULT type. Further more, the name of the value is insignificant since in the registry the default value has no name, but because of the way the node and the vb processes communicate a name must be used. Please note that the only legal value type of a default value is REG_SZ

this is a temporary solution and is subject to change in future versions

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) {    
})

For now this is how its going to be, but in the future this will probably change, possibly in a way that will effect the whole interface.

Develop

Run tests

    mocha -R spec

Enable debug output

    set DEBUG=regedit

TODO

deleteValue()

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].