node module that provides access to the Windows Registry through the REG commandline tool
The following command installs node-winreg.
npm install winreg
If you prefer to install without the delopement tools used to generate the HTML documentation (into a production environment for example) you should use the following command.
npm install winreg --production
Note that the development dependencies will not be installed if this package was installed as a dependency of another package.
The documentation is generated using jsdoc with the docstrap template. You can view the API documentation online, download the latest documentation or generate it from the sourcecode.
View the latest docs online.
To download the latest docs from GIT the following command is used.
npm run-script download-docs
To generate the docs from the sources you can use the following command.
npm run-script generate-docs
Note that generating the docs requires the development dependencies to be installed.
Let's start with an example. The code below lists the autostart programs of the current user.
var Registry = require('winreg')
, regKey = new Registry({ // new operator is optional
hive: Registry.HKCU, // open registry hive HKEY_CURRENT_USER
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' // open key containing autostart programs
})
// list autostart programs
regKey.values(function (err, items /* array of RegistryItem */) {
if (err)
console.log('ERROR: '+err);
else
for (var i=0; i<items.length; i++)
console.log('ITEM: '+items[i].name+'\t'+items[i].type+'\t'+items[i].value);
});
Since Windows Vista access to certain Registry Hives (HKEY_LOCAL_MACHINE or short HKLM for example) is restricted to processes that run in a security elevated context even if the user that starts the process is an admin. You can start a console within that context by right clicking the console shortcut and selecting the item with the shield icon called "Run as administrator" from the context menu.
Under some rare circumstances access to Registry Hives or particular keys may also be blocked by some antivirus programs or the Windows Group Policy Editor (google for gpedit.msc).
You can also use the regedit.exe tool shipped with Windows to check if you actually have access.
This project is released under BSD 2-Clause License.
Copyright (c) 2016, Paul Bottin All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.