├── .eslintignore ├── test ├── lib │ └── testscript.js ├── jsonSafe.test.js ├── benchmarks.test.js ├── list.stream.test.js ├── execFile.test.js ├── issues.test.js ├── cscript.test.js └── regedit.test.js ├── winerrors ├── run.sh ├── generateErrorDeclaration.js ├── parseErrors.js ├── generateErrorsJS.js ├── parsed.json ├── error.txt └── generatedErrorObjects.js ├── vbs ├── JsonSafeTest.wsf ├── regDeleteKey.wsf ├── regDeleteValue.wsf ├── regCreateKey.wsf ├── regList.wsf ├── regListStream.wsf ├── regPutValue.wsf ├── wsRegReadListStream.wsf ├── wsRegReadList.wsf ├── ArchitectureAgnosticRegistry.vbs ├── util.vbs ├── ArchitectureSpecificRegistry.vbs └── regUtil.vbs ├── CHANGELOG.md ├── lib ├── execFile.js ├── helper.js └── cscript.js ├── .npmignore ├── .gitignore ├── .github └── workflows │ └── test.yml ├── LICENSE ├── package.json ├── regedit.d.ts ├── .eslintrc ├── README.md ├── index.js └── errors.js /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /test/lib/testscript.js: -------------------------------------------------------------------------------- 1 | console.log('123') 2 | setTimeout(function() { 3 | throw new Error('error') 4 | }, 1000) 5 | -------------------------------------------------------------------------------- /winerrors/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | node parseErrors.js > parsed.json 3 | node generateErrorDeclaration.js > generatedErrorObjects.js 4 | node generateErrorsJS.js > ../errors1.js 5 | rm ../errors.js 6 | mv ../errors1.js ../errors.js -------------------------------------------------------------------------------- /vbs/JsonSafeTest.wsf: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /winerrors/generateErrorDeclaration.js: -------------------------------------------------------------------------------- 1 | var parsed = require('./parsed.json') 2 | 3 | for (var i = 0; i < parsed.length; i++) { 4 | var entry = parsed[i] 5 | console.log('var e%d = new Error(\'%s\')', i, entry.error) 6 | console.log('e%d.description = \'%s\'', i, entry.description) 7 | console.log('e%d.code = %d', i, entry.code) 8 | console.log('errors[%d] = e%d', entry.code, i) 9 | } 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | ### Added 10 | ### Fixed 11 | 12 | ## [5.1.3] - 2023-19-02 13 | ### Added 14 | - Add changelog file -------------------------------------------------------------------------------- /lib/execFile.js: -------------------------------------------------------------------------------- 1 | var childProcess = require('child_process') 2 | 3 | module.exports = function(options) { 4 | options = options || {} 5 | 6 | return function execFile() { 7 | 8 | var child = childProcess.execFile.apply(childProcess, arguments) 9 | 10 | if (!options.bufferStdout) { 11 | child.stdout.removeAllListeners('data') 12 | } 13 | 14 | if (!options.bufferStderr) { 15 | child.stderr.removeAllListeners('data') 16 | } 17 | 18 | return child 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Mac stuff 17 | .DS_Store 18 | 19 | # rc config files 20 | .*rc 21 | 22 | # see https://github.com/substack/browserify-handbook#organizing-modules 23 | node_modules/* 24 | !node_modules/app 25 | 26 | # Appveyor 27 | appveyor.yml -------------------------------------------------------------------------------- /test/jsonSafe.test.js: -------------------------------------------------------------------------------- 1 | var cp = require('child_process') 2 | var path = require('path') 3 | var helper = require('../lib/helper.js') 4 | var vbsScript = path.resolve(__dirname, '..', 'vbs', 'JsonSafeTest.wsf') 5 | 6 | describe.skip('json safe stream version', function() { 7 | it('also escapes windows newline', function(done) { 8 | cp.execFile('cscript', ['/NoLogo', vbsScript], function(err, stdout) { 9 | if (err) { 10 | return done(err) 11 | } 12 | 13 | JSON.parse(stdout).a.should.eql('"' + helper.ESCAPED_WIN_EOL + '测试\\') 14 | 15 | done() 16 | }) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /winerrors/parseErrors.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | 3 | var errors = fs.readFileSync('error.txt').toString() 4 | errors = errors.split(/^wbem/m) 5 | errors.shift() 6 | var results = [] 7 | 8 | for (var i = 0; i < errors.length; i++) { 9 | var splitted = errors[i].split('\n') 10 | 11 | var result = { 12 | error: 'wbem' + splitted[0], 13 | code: parseInt(splitted[1], 10), 14 | description: splitted[2], 15 | } 16 | 17 | if (result.description) { 18 | result.description = result.description.replace(/'/g, '\\\'') 19 | } 20 | 21 | results.push(result) 22 | } 23 | 24 | console.log(JSON.stringify(results)) 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Dependency directory 17 | # Commenting this out is preferred by some people, see 18 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 19 | node_modules 20 | 21 | # Mac stuff 22 | .DS_Store 23 | 24 | # rc config files 25 | .*rc 26 | !.eslintrc 27 | 28 | # see https://github.com/substack/browserify-handbook#organizing-modules 29 | node_modules/* 30 | !node_modules/app 31 | 32 | # the ultimate 1.js! (and variants) 33 | 1.js 34 | vbs/1.wsf -------------------------------------------------------------------------------- /winerrors/generateErrorsJS.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | 3 | var fs = require('fs') 4 | var START_MARKER = '// *** generated errors ***//' 5 | var END_MARKER = '// *** end generated errors ***//' 6 | 7 | var generatedErrorObjects = fs.readFileSync('./generatedErrorObjects.js', 'utf8') 8 | var errorsJs = fs.readFileSync('../errors.js', 'utf8') 9 | 10 | var start = errorsJs.indexOf(START_MARKER) 11 | var end = errorsJs.indexOf(END_MARKER, start) 12 | 13 | if (start === -1) { 14 | throw new Error('missing injection start marker') 15 | } 16 | 17 | if (end === -1) { 18 | throw new Error('missing injection end marker') 19 | } 20 | 21 | errorsJs = errorsJs.substring(0, start + START_MARKER.length) + '\n' + generatedErrorObjects + '\n' + errorsJs.substring(end) 22 | 23 | console.log(errorsJs) 24 | 25 | -------------------------------------------------------------------------------- /vbs/regDeleteKey.wsf: -------------------------------------------------------------------------------- 1 | 2 | 29 | -------------------------------------------------------------------------------- /vbs/regDeleteValue.wsf: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | -------------------------------------------------------------------------------- /vbs/regCreateKey.wsf: -------------------------------------------------------------------------------- 1 | 2 | 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI on Windows 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | workflow_dispatch: 9 | branches: [ main ] 10 | 11 | jobs: 12 | test: 13 | runs-on: windows-latest 14 | strategy: 15 | matrix: 16 | node-version: [18.x, 20.x, 22.x] 17 | 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v3 21 | 22 | - name: Setup Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | 27 | - name: Cache npm dependencies 28 | uses: actions/cache@v3 29 | with: 30 | path: ~/.npm 31 | key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }} 32 | restore-keys: | 33 | ${{ runner.os }}-npm-cache- 34 | 35 | - name: Install dependencies 36 | run: npm install 37 | 38 | - name: Run tests 39 | run: npm test -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 ironSource 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/helper.js: -------------------------------------------------------------------------------- 1 | var debug = require('debug')('regedit') 2 | var WIN_EOL = module.exports.WIN_EOL = '\r\n' 3 | 4 | module.exports.encode = function(str) { 5 | return escape(str) + WIN_EOL 6 | } 7 | 8 | /* 9 | * Write an array to a stream, taking backpressure into consideration 10 | */ 11 | module.exports.writeArrayToStream = function(arr, stream, optionalCallback) { 12 | var member = arr.pop() 13 | 14 | function write(m) { 15 | var b = module.exports.encode(m) 16 | debug(b) 17 | return stream.write(b) && arr.length > 0 18 | } 19 | 20 | while (write(member)) { 21 | member = arr.pop() 22 | } 23 | 24 | if (arr.length === 0) { 25 | stream.write(WIN_EOL, optionalCallback) 26 | return 27 | } 28 | 29 | stream.once('drain', function() { 30 | module.exports.writeArrayToStream(arr, stream, optionalCallback) 31 | }) 32 | } 33 | 34 | module.exports.vbsOutputTransform = function(chunk, enc, callback) { 35 | try { 36 | if (enc === 'buffer') { 37 | chunk = chunk.toString() 38 | } else { 39 | chunk = chunk.toString(enc) 40 | } 41 | 42 | this.push(JSON.parse(chunk)) 43 | } catch (e) { 44 | return callback(e) 45 | } 46 | 47 | return callback() 48 | } 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "regedit", 3 | "version": "5.1.3", 4 | "description": "Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host", 5 | "author": "Yaniv Kessler", 6 | "homepage": "https://github.com/kessler/node-regedit", 7 | "license": "MIT", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/kessler/node-regedit" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/kessler/node-regedit/issues" 14 | }, 15 | "keywords": [ 16 | "windows", 17 | "registry" 18 | ], 19 | "main": "index.js", 20 | "type": "commonjs", 21 | "types": "./regedit.d.ts", 22 | "scripts": { 23 | "lint": "eslint . --fix", 24 | "lint:src": "eslint . --fix --ignore-pattern test/", 25 | "lint:test": "eslint test --fix", 26 | "test": "mocha -R spec", 27 | "prepush": "npm run lint" 28 | }, 29 | "dependencies": { 30 | "debug": "^4.1.0", 31 | "if-async": "^3.7.4", 32 | "stream-slicer": "0.0.6", 33 | "through2": "^0.6.3" 34 | }, 35 | "devDependencies": { 36 | "eslint": "^8.15.0", 37 | "husky": "^0.13.4", 38 | "mocha": "^10.0.0", 39 | "should": "^13.2.3" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vbs/regList.wsf: -------------------------------------------------------------------------------- 1 | ' 2 | ' Lists the sub keys and values of a given registry key 3 | ' 4 | ' cscript regList.wsg HKLM\Software 5 | ' 6 | ' Will Yield: 7 | ' 8 | ' { 9 | ' "hklm\software": { 10 | ' "keys": [ .. array of sub keys .. ], 11 | ' "values": { 12 | ' "moo": { 13 | ' "type": "REG_SZ", 14 | ' "value": "bar" 15 | ' } 16 | ' } 17 | ' } 18 | ' } 19 | 20 | 49 | -------------------------------------------------------------------------------- /vbs/regListStream.wsf: -------------------------------------------------------------------------------- 1 | ' 2 | ' Lists the sub keys and values of a given registry key, this script is slightly different 3 | ' than regList because it reads stdin for the keys to list 4 | ' 5 | ' echo HKLM\Software | cscript regListStream.wsf A 6 | ' 7 | ' Will Yield: 8 | ' 9 | ' { 10 | ' "hklm\software": { 11 | ' "keys": [ .. array of sub keys .. ], 12 | ' "values": { 13 | ' "moo": { 14 | ' "type": "REG_SZ", 15 | ' "value": "bar" 16 | ' } 17 | ' } 18 | ' } 19 | ' } 20 | 21 | 46 | -------------------------------------------------------------------------------- /test/benchmarks.test.js: -------------------------------------------------------------------------------- 1 | var index = require('../index') 2 | 3 | describe.skip('benchmark test', function() { 4 | this.timeout(40000) 5 | 6 | var testSize = 10000 7 | var staticBaseKey = 'HKCU\\software\\ironSource\\test\\bench\\' 8 | 9 | var baseKey, keys 10 | 11 | it('create', function(done) { 12 | 13 | console.time('start create') 14 | index.createKey(keys, function(err) { 15 | if (err) { 16 | return done(err) 17 | } 18 | console.timeEnd('start create') 19 | done() 20 | }) 21 | }) 22 | 23 | it('test', function(done) { 24 | index.createKey(keys, function(err) { 25 | if (err) { 26 | return done(err) 27 | } 28 | console.timeEnd('start create') 29 | index.list(baseKey, function(err) { 30 | if (err) { 31 | return done(err) 32 | } 33 | console.time('start create') 34 | done() 35 | }) 36 | }) 37 | }) 38 | 39 | beforeEach(function() { 40 | baseKey = staticBaseKey + Date.now() 41 | 42 | // clear remains of previous tests 43 | index.deleteKey(staticBaseKey, function(err) { 44 | if (err) { 45 | console.log(err) 46 | console.log('this is of no consequence, probably.') 47 | } 48 | 49 | // create N keys for the test 50 | keys = [] 51 | 52 | for (var i = 0; i < testSize; i++) { 53 | keys.push(baseKey + '\\' + i) 54 | } 55 | }) 56 | }) 57 | }) 58 | -------------------------------------------------------------------------------- /test/list.stream.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-expressions */ 2 | 3 | var should = require('should') 4 | var index = require('../index') 5 | 6 | describe('list', function() { 7 | this.timeout(5000) 8 | 9 | it('Streaming interface', function(done) { 10 | var testKey = 'hkcu\\software' 11 | 12 | // use non streaming interface to get expected results 13 | index.list(testKey, function(err, expectedResults) { 14 | if (err) { 15 | return done(err) 16 | } 17 | 18 | var actualResults = {} 19 | var error 20 | index.list(testKey) 21 | .once('error', function(e) { 22 | should(e).be.an.Error 23 | error = e 24 | }) 25 | .on('data', function(d) { 26 | actualResults[d.key] = d.data 27 | }).once('finish', function() { 28 | actualResults.should.eql(expectedResults) 29 | done(error) 30 | }) 31 | }) 32 | }) 33 | 34 | it('works for multiple keys', function(done) { 35 | var actualResults = {} 36 | var keys = ['hklm', 'hkcu'] 37 | var error 38 | 39 | // use non streaming interface to get expected results 40 | index.list(keys, function(err, expectedResults) { 41 | if (err) { 42 | return done(err) 43 | } 44 | 45 | index.list(keys) 46 | .once('error', function(e) { 47 | error = e 48 | }) 49 | .on('data', function(d) { 50 | actualResults[d.key] = d.data 51 | }).once('finish', function() { 52 | actualResults.should.eql(expectedResults) 53 | done(error) 54 | }) 55 | }) 56 | }) 57 | }) 58 | -------------------------------------------------------------------------------- /vbs/regPutValue.wsf: -------------------------------------------------------------------------------- 1 | 2 | 56 | -------------------------------------------------------------------------------- /vbs/wsRegReadListStream.wsf: -------------------------------------------------------------------------------- 1 | ' 2 | ' Lists the values of a given registry path, this script takes its input from stdin 3 | ' 4 | ' echo HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData | cscript regListStream.wsf A 5 | ' 6 | ' Will Yield: 7 | ' 8 | ' { 9 | ' "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData": "value here" 10 | ' } 11 | 12 | 47 | -------------------------------------------------------------------------------- /vbs/wsRegReadList.wsf: -------------------------------------------------------------------------------- 1 | ' 2 | ' Lists the values of a given registry path, this script takes its input from stdin 3 | ' 4 | ' cscript regListStream.wsf A "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData" 5 | ' 6 | ' Will Yield: 7 | ' 8 | ' { 9 | ' "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData": "value here" 10 | ' } 11 | 12 | 52 | -------------------------------------------------------------------------------- /test/execFile.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len, no-unused-expressions */ 2 | 3 | var execFile = require('../lib/execFile.js') 4 | var path = require('path') 5 | 6 | var testScript = path.join(__dirname, 'lib', 'testscript.js') 7 | 8 | describe('execFile', function() { 9 | 10 | it('removes all the listeners from stdout/stderr to avoid buffering output, but enjoys all the good cleanup code node.js has to offer', function(done) { 11 | 12 | execFile()('node', [testScript], function(err, stdout, stderr) { 13 | err.should.be.an.Error 14 | stdout.should.eql('') 15 | stderr.should.eql('') 16 | done() 17 | }) 18 | }) 19 | 20 | it('does not buffer stdout', function(done) { 21 | 22 | var opts = { 23 | bufferStderr: true, 24 | } 25 | 26 | execFile(opts)('node', [testScript], function(err, stdout, stderr) { 27 | err.should.be.an.Error 28 | stdout.should.eql('') 29 | stderr.should.containEql('throw new Error(\'error\')') 30 | done() 31 | }) 32 | }) 33 | 34 | it('does not buffer stderr', function(done) { 35 | 36 | var opts = { 37 | bufferStdout: true, 38 | } 39 | 40 | execFile(opts)('node', [testScript], function(err, stdout, stderr) { 41 | err.should.be.an.Error 42 | stdout.should.eql('123\n') 43 | stderr.should.eql('') 44 | done() 45 | }) 46 | }) 47 | 48 | it('buffers everything', function(done) { 49 | 50 | var opts = { 51 | bufferStdout: true, 52 | bufferStderr: true, 53 | } 54 | 55 | execFile(opts)('node', [testScript], function(err, stdout, stderr) { 56 | err.should.be.an.Error 57 | stdout.should.eql('123\n') 58 | stderr.should.containEql('throw new Error(\'error\')') 59 | done() 60 | }) 61 | }) 62 | }) 63 | -------------------------------------------------------------------------------- /test/issues.test.js: -------------------------------------------------------------------------------- 1 | // TODO need to find a better way to test the 32bit/64bit specific scenarios 2 | 3 | var index = require('../index') 4 | 5 | describe('regedit', function() { 6 | var baseKey = 'HKCU\\software\\ironSource\\regedit\\issues-test\\' 7 | var key 8 | 9 | // this test fails with a timeout because putValue callback is never invoked 10 | it('putValue with empty string for value fails silently #8', function(done) { 11 | 12 | index.createKey(key, function(err) { 13 | if (err) { 14 | return done(err) 15 | } 16 | 17 | var values = {} 18 | 19 | values[key] = { 'valName': { value: '', type: 'REG_SZ' } } 20 | 21 | index.putValue(values, function(err) { 22 | if (err) { 23 | return done(err) 24 | } 25 | 26 | index.list(key, function(err, results) { 27 | if (err) { 28 | return done(err) 29 | } 30 | 31 | results.should.have.property(key) 32 | .which.have.property('values') 33 | .which.have.property('valName') 34 | .which.have.property('value', '') 35 | 36 | done() 37 | }) 38 | }) 39 | }) 40 | 41 | }) 42 | 43 | it('can putValue REG_DWORD > 0x7fffffff #21', function(done) { 44 | index.createKey(key, function(err) { 45 | if (err) { 46 | return done(err) 47 | } 48 | 49 | var values = {} 50 | 51 | values[key] = { 'valName': { value: 0x80000000, type: 'REG_DWORD' } } 52 | 53 | index.putValue(values, function(err) { 54 | if (err) { 55 | return done(err) 56 | } 57 | 58 | index.list(key, function(err, results) { 59 | if (err) { 60 | return done(err) 61 | } 62 | 63 | results.should.have.property(key) 64 | .which.have.property('values') 65 | .which.have.property('valName') 66 | .which.have.property('value', 0x80000000) 67 | 68 | done() 69 | }) 70 | }) 71 | }) 72 | }) 73 | 74 | it('can putValue REG_QWORD < 9007199254740993 #21', function(done) { 75 | index.createKey(key, function(err) { 76 | if (err) { 77 | return done(err) 78 | } 79 | 80 | var values = {} 81 | 82 | values[key] = { 'valName': { value: 9007199254740993, type: 'REG_QWORD' } } 83 | 84 | index.putValue(values, function(err) { 85 | if (err) { 86 | return done(err) 87 | } 88 | 89 | index.list(key, function(err, results) { 90 | if (err) { 91 | return done(err) 92 | } 93 | 94 | results.should.have.property(key) 95 | .which.have.property('values') 96 | .which.have.property('valName') 97 | .which.have.property('value', 9007199254740992) 98 | 99 | done() 100 | }) 101 | 102 | }) 103 | }) 104 | }) 105 | 106 | beforeEach(function() { 107 | key = baseKey + Date.now() 108 | }) 109 | }) 110 | -------------------------------------------------------------------------------- /vbs/ArchitectureAgnosticRegistry.vbs: -------------------------------------------------------------------------------- 1 | ' Notes: wanted to implement this using a class but: 2 | ' 1. No matter what I did I could not assign the result of GetObject to a private member 3 | ' 2. It looks as if all methods were treated as subs from the outside world which is not good since 4 | ' some of these need to return a value 5 | ' 6 | 7 | Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv") 8 | 9 | Function SetStringValue(constHive, strSubKey, strValueName, strValue) 10 | SetStringValue = private_oReg.SetStringValue(constHive, strSubKey, strValueName, strValue) 11 | End Function 12 | 13 | Sub GetStringValue(constHive, strKey, strValueName, strValue) 14 | private_oReg.GetStringValue constHive, strKey, strValueName, strValue 15 | End Sub 16 | 17 | Function SetExpandedStringValue(constHive, strSubKey, strValueName, strValue) 18 | SetExpandedStringValue = private_oReg.SetExpandedStringValue(constHive, strSubKey, strValueName, strValue) 19 | End Function 20 | 21 | Sub GetExpandedStringValue(constHive, strKey, strValueName, strValue) 22 | private_oReg.GetExpandedStringValue constHive, strKey, strValueName, strValue 23 | End Sub 24 | 25 | Function SetMultiStringValue(constHive, strSubKey, strValueName, arrValue) 26 | SetMultiStringValue = private_oReg.SetMultiStringValue(constHive, strSubKey, strValueName, arrValue) 27 | End Function 28 | 29 | Sub GetMultiStringValue(constHive, strKey, strValueName, arrStrValue) 30 | private_oReg.GetMultiStringValue constHive, strKey, strValueName, arrStrValue 31 | End Sub 32 | 33 | Function SetDWORDValue(constHive, strSubKey, strValueName, arrValue) 34 | SetDWORDValue = private_oReg.SetDWORDValue(constHive, strSubKey, strValueName, arrValue) 35 | End Function 36 | 37 | Sub GetDWORDValue(constHive, strKey, strValueName, intDWordValue) 38 | private_oReg.GetDWORDValue constHive, strKey, strValueName, intDWordValue 39 | End Sub 40 | 41 | Function SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue) 42 | SetQWORDValue = private_oReg.SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue) 43 | End Function 44 | 45 | Sub GetQWORDValue(constHive, strKey, strValueName, intQWordValue) 46 | private_oReg.GetQWORDValue constHive, strKey, strValueName, intQWordValue 47 | End Sub 48 | 49 | Function SetBinaryValue(constHive, strSubKey, strValueName, arrValue) 50 | SetBinaryValue = private_oReg.SetBinaryValue(constHive, strSubKey, strValueName, arrValue) 51 | End Function 52 | 53 | Sub GetBinaryValue(constHive, strKey, strValueName, arrBinaryValue) 54 | private_oReg.GetBinaryValue constHive, strKey, strValueName, arrBinaryValue 55 | End Sub 56 | 57 | Function EnumKey(constHive, strSubKey, arrKeyNames) 58 | EnumKey = private_oReg.EnumKey(constHive, strSubKey, arrKeyNames) 59 | End Function 60 | 61 | Function EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes) 62 | EnumValues = private_oReg.EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes) 63 | End Function 64 | 65 | Function CreateKey(constHive, strSubKey) 66 | CreateKey = private_oReg.CreateKey(constHive, strSubKey) 67 | End Function 68 | 69 | Function DeleteKey(constHive, strSubKey) 70 | DeleteKey = private_oReg.DeleteKey(constHive, strSubKey) 71 | End Function 72 | 73 | Function DeleteValue(constHive, strSubKey, strValue) 74 | DeleteValue = private_oReg.DeleteValue(constHive, strSubKey, strValue) 75 | End Function 76 | -------------------------------------------------------------------------------- /lib/cscript.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable global-require */ 2 | 3 | var ifAsync 4 | var fs 5 | var execFile 6 | var debug 7 | var init 8 | 9 | /* 10 | * when we mock stuff we need a way to reset 11 | */ 12 | function resetDependencies() { 13 | init = false 14 | ifAsync = require('if-async') 15 | fs = require('fs') 16 | execFile = require('../lib/execFile.js')({ bufferStdout: true, bufferStderr: true }) 17 | debug = require('debug')('regedit:cscript') 18 | } 19 | 20 | resetDependencies() 21 | 22 | /* 23 | * expected output for failed where.exe execution, exported for testing purposes 24 | */ 25 | var CSCRIPT_NOT_FOUND = module.exports.CSCRIPT_NOT_FOUND = 'INFO: Could not find files for the given pattern(s).' 26 | 27 | /* 28 | * expected output for cscript.exe, exported for testing purposes 29 | */ 30 | var CSCRIPT_EXPECTED_OUTPUT = module.exports.CSCRIPT_EXPECTED_OUTPUT = 'Microsoft (R) Windows Script Host Version' 31 | 32 | var cscript = 'cscript.exe' 33 | 34 | function spawnCScriptSucceeded(callback) { 35 | debug('spawnCScriptSucceeded()') 36 | 37 | execFile('cscript.exe', function(err, stdout) { 38 | 39 | if (err) { 40 | // where command not found on this system 41 | if (err.code === 'ENOENT') { 42 | return callback(null, false) 43 | } 44 | return callback(err) 45 | 46 | } 47 | 48 | cscript = 'cscript.exe' 49 | callback(null, stdout.indexOf(CSCRIPT_EXPECTED_OUTPUT) > -1) 50 | }) 51 | } 52 | 53 | function whereCScriptSucceeded(callback) { 54 | debug('whereCScriptSucceeded()') 55 | 56 | execFile('where cscript.exe', function(err, stdout) { 57 | 58 | if (err) { 59 | // where command not found on this system 60 | if (err.code === 'ENOENT') { 61 | return callback(null, false) 62 | } 63 | return callback(err) 64 | 65 | } 66 | 67 | if (typeof stdout !== 'string') { 68 | return callback(null, false) 69 | } 70 | if (stdout.indexOf(CSCRIPT_NOT_FOUND) > -1) { 71 | return callback(null, false) 72 | } 73 | 74 | cscript = stdout.trim() 75 | callback(null, true) 76 | }) 77 | } 78 | 79 | function fsStatCScriptSucceeded(callback) { 80 | debug('fsStatCScriptSucceeded()') 81 | 82 | fs.stat('c:\\windows\\system32\\cscript.exe', function(err) { 83 | if (err) { 84 | if (err.code === 'ENOENT') { 85 | return callback(null, false) 86 | } 87 | return callback(err) 88 | 89 | } 90 | 91 | cscript = 'c:\\windows\\system32\\cscript.exe' 92 | callback(null, true) 93 | }) 94 | } 95 | 96 | function callbackWithError(cb) { 97 | cb(new Error('cscript not found')) 98 | } 99 | 100 | module.exports.path = function() { 101 | // this sucks... 102 | if (init === false) { 103 | throw new Error('must initialize first') 104 | } 105 | debug(cscript) 106 | return cscript 107 | } 108 | 109 | module.exports.init = function(callback) { 110 | debug('init()') 111 | 112 | if (init) { 113 | debug('already initialized') 114 | return setImmediate(callback) 115 | } 116 | 117 | var functor = 118 | ifAsync(spawnCScriptSucceeded) 119 | .or(whereCScriptSucceeded) 120 | .or(fsStatCScriptSucceeded) 121 | .then(function(cb) { 122 | init = true 123 | cb() 124 | }) 125 | .else(callbackWithError) 126 | 127 | functor(function(err) { 128 | if (err) { 129 | return callback(err) 130 | } 131 | callback() 132 | }) 133 | } 134 | 135 | module.exports._mock = function(_fs, _execFile, _init) { 136 | fs = _fs 137 | execFile = _execFile 138 | init = _init 139 | } 140 | 141 | module.exports._mockReset = resetDependencies 142 | -------------------------------------------------------------------------------- /test/cscript.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable consistent-this */ 2 | 3 | var cscript = require('../lib/cscript.js') 4 | 5 | describe('cscript', function() { 6 | var mockFs, mockExecFile 7 | 8 | it('must be initialized', function() { 9 | (function() { 10 | cscript.path() 11 | }).should.throw('must initialize first') 12 | }) 13 | 14 | it('if cscript.exe is successfully spawned then no more checks are conducted', function(done) { 15 | mockExecFile['cscript.exe'].calls.should.eql(0) 16 | mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT 17 | 18 | cscript.init(function(err) { 19 | if (err) { 20 | return done(err) 21 | } 22 | 23 | mockExecFile['cscript.exe'].calls.should.eql(1) 24 | mockExecFile['cscript.exe'].args[0].should.eql('cscript.exe') 25 | done() 26 | }) 27 | }) 28 | 29 | it('initializes only once', function(done) { 30 | 31 | mockExecFile['cscript.exe'].calls.should.eql(0) 32 | mockExecFile['cscript.exe'].stdout = cscript.CSCRIPT_EXPECTED_OUTPUT 33 | 34 | cscript.init(function(err) { 35 | if (err) { 36 | return done(err) 37 | } 38 | 39 | mockExecFile['cscript.exe'].calls.should.eql(1) 40 | 41 | cscript.init(function(err) { 42 | if (err) { 43 | return done(err) 44 | } 45 | 46 | mockExecFile['cscript.exe'].calls.should.eql(1) 47 | mockExecFile['where cscript.exe'].calls.should.eql(0) 48 | done() 49 | }) 50 | }) 51 | }) 52 | 53 | it('if cscript.exe fails to execute, try to run "where cscript.exe"', function(done) { 54 | mockExecFile['cscript.exe'].calls.should.eql(0) 55 | mockExecFile['where cscript.exe'].calls.should.eql(0) 56 | 57 | mockExecFile['cscript.exe'].err = new Error() 58 | mockExecFile['cscript.exe'].err.code = 'ENOENT' 59 | mockExecFile['where cscript.exe'].stdout = '123' 60 | 61 | cscript.init(function(err) { 62 | if (err) { 63 | return done(err) 64 | } 65 | 66 | mockExecFile['cscript.exe'].calls.should.eql(1) 67 | mockExecFile['where cscript.exe'].calls.should.eql(1) 68 | 69 | cscript.path().should.eql('123') 70 | done() 71 | }) 72 | }) 73 | 74 | beforeEach(function() { 75 | mockFs = { 76 | err: null, 77 | calls: 0, 78 | stat: function(name, cb) { 79 | this.calls++ 80 | var self = this 81 | setImmediate(function() { 82 | cb(self.err, {}) 83 | }) 84 | }, 85 | } 86 | 87 | mockExecFile = function(command, args, options, callback) { 88 | if (!mockExecFile[command]) { 89 | throw new Error('unexpected command ' + command) 90 | } 91 | 92 | mockExecFile[command].args = arguments 93 | mockExecFile[command].calls++ 94 | 95 | if (typeof args === 'function') { 96 | callback = args 97 | args = undefined 98 | options = undefined 99 | } 100 | 101 | if (typeof options === 'function') { 102 | callback = options 103 | args = undefined 104 | options = undefined 105 | } 106 | 107 | if (typeof callback !== 'function') { 108 | throw new Error('missing callback') 109 | } 110 | 111 | setImmediate(function() { 112 | callback(mockExecFile[command].err, mockExecFile[command].stdout, mockExecFile[command].stderr) 113 | }) 114 | } 115 | 116 | mockExecFile['cscript.exe'] = { calls: 0, stdout: '', stderr: '', err: null } 117 | mockExecFile['where cscript.exe'] = { calls: 0, stdout: '', stderr: '', err: null } 118 | 119 | cscript._mock(mockFs, mockExecFile, false) 120 | }) 121 | 122 | afterEach(function() { 123 | cscript._mockReset() 124 | }) 125 | }) 126 | -------------------------------------------------------------------------------- /vbs/util.vbs: -------------------------------------------------------------------------------- 1 | Set stdout = WScript.StdOut 2 | Set stderr = WScript.StdErr 3 | Set stdin = WScript.StdIn 4 | Set args = WScript.Arguments 5 | Set fs = CreateObject("scripting.filesystemobject") 6 | Dim OSArchitecture 7 | 8 | Sub WriteErr(message) 9 | stderr.Write message 10 | End Sub 11 | 12 | Sub WriteLineErr(message) 13 | stderr.WriteLine message 14 | End Sub 15 | 16 | Sub Write(message) 17 | stdout.Write message 18 | End Sub 19 | 20 | Sub WriteLine(message) 21 | stdout.WriteLine message 22 | End Sub 23 | 24 | Function IndexOf(varNeedle, arrHaystack) 25 | IndexOf = -1 26 | 27 | If Not IsArray(arrHaystack) Then 28 | Exit Function 29 | End If 30 | 31 | For xyz = 0 To UBound(arrHaystack) 32 | If arrHaystack(xyz) = varNeedle Then 33 | IndexOf = xyz 34 | Exit Function 35 | End If 36 | Next 37 | End Function 38 | 39 | Sub CheckZeroArgs(message) 40 | ' bail if args are missing 41 | If args.Count = 0 Then 42 | WriteLineErr message 43 | WScript.Quit 25121 44 | End If 45 | End Sub 46 | 47 | Dim ALLOWED_OS_ARCHITECTURE_VALUES: ALLOWED_OS_ARCHITECTURE_VALUES = Array("S", "A", "32", "64") 48 | 49 | ' 50 | ' determine the architecture of the operating system, that will be used. there are 4 possibilities: 51 | ' A - means agnostic 52 | ' S - means that we want to use a specific architecture, but auto detect Item 53 | ' 32 - explicitly use 32 bit architecture 54 | ' 64 - explicitly use 64 bit architecture 55 | ' 56 | Sub DetermineOSArchitecture() 57 | strArchitecture = args(0) 58 | 59 | If IsNull(strArchitecture) Then 60 | WriteLineErr "missing architecture argument" 61 | WScript.Quit 25124 62 | End If 63 | 64 | strArchitecture = UCase(strArchitecture) 65 | 66 | If IndexOf(strArchitecture, ALLOWED_OS_ARCHITECTURE_VALUES) = -1 Then 67 | WriteLineErr "invalid architecture argument" 68 | WScript.Quit 25124 69 | End If 70 | 71 | If (strArchitecture = "S") Then 72 | OSArchitecture = GetOSArchitecture() 73 | If OSArchitecture = -1 Then 74 | WriteLineErr "invalid os architecture detected " & OSArchitecture 75 | WScript.Quit 25126 76 | End If 77 | Else 78 | OSArchitecture = strArchitecture 79 | End If 80 | 81 | End Sub 82 | 83 | Sub Include(sPath) 84 | ' TODO this is fragile, but should work for "modules" nested relatively to script root 85 | include_ScriptPath = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName) - 2) 86 | sPath = include_ScriptPath & "\" & sPath 87 | 88 | include_code = fs.OpenTextFile(sPath).ReadAll 89 | ExecuteGlobal include_code 90 | End Sub 91 | 92 | Function GetOSArchitecture() 93 | 94 | Dim ObjWMI, ColSettings, ObjProcessor 95 | Dim StrComputer, ObjNetwork 96 | 97 | Set ObjWMI = GetObject("winmgmts:\Root\CIMV2") 98 | Set ColSettings = ObjWMI.ExecQuery ("SELECT DataWidth, AddressWidth, Architecture FROM Win32_Processor") 99 | 100 | ' I make two assumptions here: 101 | ' 1. Eveyone will have CPU0 device 102 | ' 2. There is only one cpu defined in the wmi database (and if not, then they are all of the same architecture) 103 | ' 104 | ' from: https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor 105 | ' Architecture values: 106 | ' x86 (0) 107 | ' MIPS (1) 108 | ' Alpha (2) 109 | ' PowerPC (3) 110 | ' ARM (5) 111 | ' ia64 (6) 112 | ' x64 (9) 113 | ' ARM64 (12) 114 | 115 | Set ObjProcessor = ColSettings.Item("Win32_Processor.DeviceID=""CPU0""") 116 | 117 | If ObjProcessor.Architecture = 0 AND ObjProcessor.AddressWidth = 32 Then 118 | GetOSArchitecture = 32 119 | ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 32 Then 120 | GetOSArchitecture = 32 121 | ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 122 | GetOSArchitecture = 64 123 | ' special case (could be included in the statements above) for Windows VM on Apple Silicon, tested only on parallels 124 | ElseIf ObjProcessor.Architecture = 12 AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 125 | GetOSArchitecture = 64 126 | Else 127 | GetOSArchitecture = -1 128 | End If 129 | 130 | End Function 131 | 132 | Function JsonSafe(inStrText) 133 | If inStrText = "" Then 134 | JsonSafe = "" 135 | Exit Function 136 | End If 137 | Dim outStrText: outStrText = inStrText 138 | outStrText = Replace(outStrText, "\", "\\") 139 | outStrText = Replace(outStrText, vbcrlf, "\\r\\n") 140 | outStrText = Replace(outStrText, vblf, "\\n") 141 | outStrText = Replace(outStrText, vbcr, "\\r") 142 | outStrText = Replace(outStrText, """", "\""") 143 | outStrText = JsonU(outStrText) 144 | JsonSafe = outStrText 145 | End Function 146 | 147 | 'TODO: need to change this function's name to something more appropriate 148 | Function JsonU(astr) 149 | 150 | If isNull(astr) Then 151 | JsonU = "" 152 | Exit Function 153 | End If 154 | 155 | Dim c 156 | Dim utftext: utftext = "" 157 | 158 | For n = 1 To Len(astr) 159 | c = CLng(AscW(Mid(astr, n, 1))) 160 | 161 | If c < 0 Then 162 | c = &H10000 + c 163 | End If 164 | 165 | If c < &H80 Then 166 | utftext = utftext & Mid(astr, n, 1) 167 | ElseIf c < &H100 Then 168 | utftext = utftext & "\u00" & Hex(c) 169 | ElseIf c < &H1000 Then 170 | utftext = utftext & "\u0" & Hex(c) 171 | Else 172 | utftext = utftext & "\u" & Hex(c) 173 | End If 174 | Next 175 | 176 | JsonU = utftext 177 | End Function 178 | -------------------------------------------------------------------------------- /regedit.d.ts: -------------------------------------------------------------------------------- 1 | export interface REG_SZ_Value { 2 | value: string; 3 | type: "REG_SZ"; 4 | } 5 | 6 | export interface REG_EXPAND_SZ_Value { 7 | value: string; 8 | type: "REG_EXPAND_SZ"; 9 | } 10 | 11 | export interface REG_DWORD_Value { 12 | value: number; 13 | type: "REG_DWORD"; 14 | } 15 | 16 | export interface REG_QWORD_Value { 17 | value: number; 18 | type: "REG_QWORD"; 19 | } 20 | 21 | export interface REG_MULTI_SZ_Value { 22 | value: string[]; 23 | type: "REG_MULTI_SZ"; 24 | } 25 | 26 | export interface REG_BINARY_Value { 27 | value: number[]; 28 | type: "REG_SZ"; 29 | } 30 | 31 | export interface REG_DEFAULT_Value { 32 | value: string; 33 | type: "REG_DEFAULT"; 34 | } 35 | 36 | export type RegistryItemValue = REG_SZ_Value | REG_EXPAND_SZ_Value | REG_DWORD_Value | REG_QWORD_Value | REG_MULTI_SZ_Value | REG_BINARY_Value | REG_DEFAULT_Value; 37 | 38 | export interface RegistryItem { 39 | exists: boolean; 40 | keys: string[]; 41 | values: { 42 | [name: string]: RegistryItemValue; 43 | }; 44 | } 45 | 46 | export type RegistryItemCollection = U; 47 | 48 | export interface RegistryPutItem { 49 | [name: string]: RegistryItemValue; 50 | } 51 | 52 | export type RegistryItemPutCollection = { 53 | [key: string]: RegistryPutItem; 54 | }; 55 | 56 | export const OS_ARCH_AGNOSTIC = "A"; 57 | export const OS_ARCH_SPECIFIC = "S"; 58 | export const OS_ARCH_32BIT = "32"; 59 | export const OS_ARCH_64BIT = "64"; 60 | 61 | type Architecture = (typeof OS_ARCH_AGNOSTIC | typeof OS_ARCH_SPECIFIC | typeof OS_ARCH_32BIT | typeof OS_ARCH_64BIT); 62 | type ErrResCallback = (err: Error | undefined, res: RegistryItemCollection) => void; 63 | 64 | export function list(keys: readonly K[], callback: ErrResCallback): void; 65 | export function list(keys: readonly K[], architecture: Architecture, callback?: ErrResCallback): void; 66 | 67 | export function setExternalVBSLocation(newLocation: string): string; 68 | 69 | interface ErrorWithCode extends Error { 70 | code: number; 71 | description: string; 72 | } 73 | 74 | type ErrCallback = (err: ErrorWithCode | undefined) => void; 75 | 76 | export function createKey(keys: readonly K[], callback: ErrCallback): void; 77 | export function createKey(keys: readonly K[], architecture: Architecture, callback?: ErrCallback): void; 78 | 79 | export function deleteKey(keys: readonly string[], callback: ErrCallback): void; 80 | export function deleteKey(keys: readonly string[], architecture: Architecture, callback?: ErrCallback): void; 81 | 82 | export function putValue(map: RegistryItemPutCollection, callback: ErrCallback): void; 83 | export function putValue(map: RegistryItemPutCollection, architecture: Architecture, callback?: ErrCallback): void; 84 | 85 | export namespace arch { 86 | export function list(keys: readonly K[], callback: ErrResCallback): void; 87 | export function list32(keys: readonly K[], callback: ErrResCallback): void; 88 | export function list64(keys: readonly K[], callback: ErrResCallback): void; 89 | export function createKey(keys: readonly string[], callback: ErrCallback): void; 90 | export function createKey32(keys: readonly string[], callback: ErrCallback): void; 91 | export function createKey64(keys: readonly string[], callback: ErrCallback): void; 92 | export function deleteKey(keys: readonly string[], callback: ErrCallback): void; 93 | export function deleteKey32(keys: readonly string[], callback: ErrCallback): void; 94 | export function deleteKey64(keys: readonly string[], callback: ErrCallback): void; 95 | export function putValue(map: RegistryItemPutCollection, callback: ErrCallback): void; 96 | export function putValue32(map: RegistryItemPutCollection, callback: ErrCallback): void; 97 | export function putValue64(map: RegistryItemPutCollection, callback: ErrCallback): void; 98 | } 99 | 100 | export namespace promisified { 101 | export function list(keys: readonly K[]): Promise>; 102 | export function list(keys: readonly K[], architecture: Architecture): Promise>; 103 | export function createKey(keys: readonly string[]): Promise; 104 | export function createKey(keys: readonly string[], architecture: Architecture): Promise; 105 | export function deleteKey(keys: readonly string[]): Promise; 106 | export function deleteKey(keys: readonly string[], architecture: Architecture): Promise; 107 | export function putValue(map: RegistryItemPutCollection): Promise; 108 | export function putValue(map: RegistryItemPutCollection, architecture: Architecture): Promise; 109 | 110 | export namespace arch { 111 | export function list(keys: readonly K[]): Promise>; 112 | export function list32(keys: readonly K[]): Promise>; 113 | export function list64(keys: readonly K[]): Promise>; 114 | export function createKey(keys: readonly string[]): Promise; 115 | export function createKey32(keys: readonly string[]): Promise; 116 | export function createKey64(keys: readonly string[]): Promise; 117 | export function deleteKey(keys: readonly string[]): Promise; 118 | export function deleteKey32(keys: readonly string[]): Promise; 119 | export function deleteKey64(keys: readonly string[]): Promise; 120 | export function putValue(map: RegistryItemPutCollection): Promise; 121 | export function putValue32(map: RegistryItemPutCollection): Promise; 122 | export function putValue64(map: RegistryItemPutCollection): Promise; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "commonjs": true, 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "rules": { 9 | "semi": [ 10 | "error", 11 | "never" 12 | ], 13 | "no-const-assign": "error", 14 | "no-this-before-super": "error", 15 | "no-undef": "error", 16 | "no-unreachable": "warn", 17 | "no-unused-vars": "warn", 18 | "constructor-super": "warn", 19 | "valid-typeof": "error", 20 | "no-cond-assign": "error", 21 | "no-dupe-args": "error", 22 | "no-dupe-keys": "error", 23 | "no-duplicate-case": "error", 24 | "no-extra-boolean-cast": "warn", 25 | "no-extra-semi": "error", 26 | "no-func-assign": "error", 27 | "no-invalid-regexp": "error", 28 | "no-template-curly-in-string": "error", 29 | "no-unsafe-negation": "error", 30 | "use-isnan": "error", 31 | "valid-jsdoc": "warn", 32 | "callback-return": "error", 33 | "array-callback-return": "error", 34 | "class-methods-use-this": "warn", 35 | "complexity": [ 36 | "error", 37 | 15 38 | ], 39 | "curly": [ 40 | "error", 41 | "all" 42 | ], 43 | "default-case": "warn", 44 | "dot-location": [ 45 | "error", 46 | "property" 47 | ], 48 | "dot-notation": [ 49 | "error", 50 | { 51 | "allowKeywords": true 52 | } 53 | ], 54 | "eqeqeq": "error", 55 | "guard-for-in": "warn", 56 | "no-alert": "error", 57 | "no-caller": "error", 58 | "no-else-return": "error", 59 | "no-div-regex": "error", 60 | "no-case-declarations": "error", 61 | "no-empty-function": "warn", 62 | "no-empty-pattern": "error", 63 | "no-eq-null": "error", 64 | "no-eval": "error", 65 | "no-extend-native": "error", 66 | "no-extra-bind": "warn", 67 | "no-extra-label": "warn", 68 | "no-fallthrough": "error", 69 | "no-global-assign": "error", 70 | "no-floating-decimal": "warn", 71 | "no-implicit-coercion": "error", 72 | "no-implied-eval": "error", 73 | "no-invalid-this": "error", 74 | "no-iterator": "error", 75 | "no-labels": "error", 76 | "no-lone-blocks": "warn", 77 | "no-loop-func": "error", 78 | "no-magic-numbers": "off", 79 | "no-multi-spaces": "warn", 80 | "no-multi-str": "error", 81 | "no-new-func": "error", 82 | "no-new-wrappers": "error", 83 | "no-new": "error", 84 | "no-proto": "error", 85 | "no-redeclare": "error", 86 | "no-return-assign": "error", 87 | "no-return-await": "error", 88 | "no-script-url": "error", 89 | "no-self-assign": "error", 90 | "no-self-compare": "error", 91 | "no-sequences": "error", 92 | "no-throw-literal": "error", 93 | "no-unmodified-loop-condition": "error", 94 | "no-unused-expressions": "error", 95 | "no-unused-labels": "error", 96 | "no-useless-call": "error", 97 | "no-useless-concat": "warn", 98 | "no-useless-escape": "warn", 99 | "no-useless-return": "error", 100 | "no-void": "error", 101 | "no-warning-comments": "warn", 102 | "no-with": "error", 103 | "radix": "warn", 104 | "require-await": "error", 105 | "vars-on-top": "off", 106 | "wrap-iife": "error", 107 | "yoda": "error", 108 | "no-catch-shadow": "error", 109 | "no-delete-var": "error", 110 | "no-label-var": "error", 111 | "no-restricted-globals": "error", 112 | "no-shadow-restricted-names": "error", 113 | "no-undef-init": "warn", 114 | "no-undefined": "off", 115 | "no-use-before-define": "warn", 116 | "global-require": "error", 117 | "handle-callback-err": "warn", 118 | "no-mixed-requires": "error", 119 | "no-new-require": "error", 120 | "no-path-concat": "warn", 121 | "no-process-exit": "warn", 122 | "array-bracket-spacing": [ 123 | "error", 124 | "never" 125 | ], 126 | "block-spacing": [ 127 | "error", 128 | "always" 129 | ], 130 | "brace-style": [ 131 | "error" 132 | ], 133 | "camelcase": "error", 134 | "comma-dangle": [ 135 | "warn", 136 | "always-multiline" 137 | ], 138 | "comma-spacing": [ 139 | "error", 140 | { 141 | "after": true 142 | } 143 | ], 144 | "comma-style": [ 145 | "error", 146 | "last" 147 | ], 148 | "computed-property-spacing": [ 149 | "error", 150 | "never" 151 | ], 152 | "consistent-this": [ 153 | "error", 154 | "that" 155 | ], 156 | "eol-last": "error", 157 | "func-call-spacing": [ 158 | "error", 159 | "never" 160 | ], 161 | "func-name-matching": [ 162 | "warn", 163 | "always" 164 | ], 165 | "func-names": [ 166 | "off", 167 | "as-needed" 168 | ], 169 | "func-style": [ 170 | "warn", 171 | "declaration", 172 | { 173 | "allowArrowFunctions": true 174 | } 175 | ], 176 | "indent": [ 177 | "error", 178 | tab, 179 | { 180 | "SwitchCase": 1 181 | } 182 | ], 183 | "jsx-quotes": [ 184 | "error", 185 | "prefer-double" 186 | ], 187 | "key-spacing": [ 188 | "error", 189 | { 190 | "afterColon": true 191 | } 192 | ], 193 | "linebreak-style": [ 194 | "warn", 195 | "unix" 196 | ], 197 | "lines-around-directive": [ 198 | "warn", 199 | "always" 200 | ], 201 | "max-depth": [ 202 | "error", 203 | 4 204 | ], 205 | "max-len": [ 206 | "error", 207 | 140 208 | ], 209 | "max-nested-callbacks": [ 210 | "error", 211 | 8 212 | ], 213 | "max-params": [ 214 | "error", 215 | 4 216 | ], 217 | "object-curly-spacing": [ 218 | "warn", 219 | "always" 220 | ] 221 | } 222 | } -------------------------------------------------------------------------------- /vbs/ArchitectureSpecificRegistry.vbs: -------------------------------------------------------------------------------- 1 | ' Notes: wanted to implement this using a class but: 2 | ' 1. No matter what I did I could not assign the result of GetObject to a private member 3 | ' 2. It looks as if all methods were treated as subs from the outside world which is not good since 4 | ' some of these need to return a value 5 | 6 | ' should be removed when migration is complete 7 | Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv") 8 | 9 | Set private_oCtx = CreateObject("WbemScripting.SWbemNamedValueSet") 10 | private_oCtx.Add "__ProviderArchitecture", CInt(OSArchitecture) 11 | 12 | Set private_oLocator = CreateObject("Wbemscripting.SWbemLocator") 13 | Set private_oServices = private_oLocator.ConnectServer(".", "root\default","","",,,,private_oCtx) 14 | Set private_oRegSpecific = private_oServices.Get("StdRegProv") 15 | 16 | Function CheckAccess(hDefKey,sSubKeyName,uRequired, bGranted ) 17 | Set Inparams = private_oRegSpecific.Methods_("CheckAccess").Inparameters 18 | 19 | Inparams.hDefKey = hDefKey 20 | 21 | Inparams.sSubKeyName = sSubKeyName 22 | 23 | Inparams.uRequired = uRequired 24 | 25 | set Outparams = private_oRegSpecific.ExecMethod_("CheckAccess", Inparams,,private_oCtx) 26 | 27 | bGranted = Outparams.bGranted 28 | 29 | 30 | CheckAccess = 0 31 | 32 | End Function 33 | 34 | Function CreateKey(hDefKey,sSubKeyName) 35 | Set Inparams = private_oRegSpecific.Methods_("CreateKey").Inparameters 36 | 37 | Inparams.hDefKey = hDefKey 38 | 39 | Inparams.sSubKeyName = sSubKeyName 40 | 41 | set Outparams = private_oRegSpecific.ExecMethod_("CreateKey", Inparams,,private_oCtx) 42 | 43 | 44 | CreateKey = 0 45 | 46 | End Function 47 | 48 | Function DeleteKey(hDefKey,sSubKeyName) 49 | Set Inparams = private_oRegSpecific.Methods_("DeleteKey").Inparameters 50 | 51 | Inparams.hDefKey = hDefKey 52 | 53 | Inparams.sSubKeyName = sSubKeyName 54 | 55 | set Outparams = private_oRegSpecific.ExecMethod_("DeleteKey", Inparams,,private_oCtx) 56 | 57 | 58 | DeleteKey = 0 59 | 60 | End Function 61 | 62 | Function DeleteValue(hDefKey,sSubKeyName,sValueName) 63 | Set Inparams = private_oRegSpecific.Methods_("DeleteValue").Inparameters 64 | 65 | Inparams.hDefKey = hDefKey 66 | 67 | Inparams.sSubKeyName = sSubKeyName 68 | 69 | Inparams.sValueName = sValueName 70 | 71 | set Outparams = private_oRegSpecific.ExecMethod_("DeleteValue", Inparams,,private_oCtx) 72 | 73 | 74 | DeleteValue = 0 75 | 76 | End Function 77 | 78 | Function EnumKey(hDefKey,sSubKeyName, sNames ) 79 | Set Inparams = private_oRegSpecific.Methods_("EnumKey").Inparameters 80 | 81 | Inparams.hDefKey = hDefKey 82 | 83 | Inparams.sSubKeyName = sSubKeyName 84 | 85 | set Outparams = private_oRegSpecific.ExecMethod_("EnumKey", Inparams,,private_oCtx) 86 | 87 | sNames = Outparams.sNames 88 | 89 | 90 | EnumKey = 0 91 | 92 | End Function 93 | 94 | Function EnumValues(hDefKey,sSubKeyName, sNames,Types ) 95 | Set Inparams = private_oRegSpecific.Methods_("EnumValues").Inparameters 96 | 97 | Inparams.hDefKey = hDefKey 98 | 99 | Inparams.sSubKeyName = sSubKeyName 100 | 101 | set Outparams = private_oRegSpecific.ExecMethod_("EnumValues", Inparams,,private_oCtx) 102 | 103 | sNames = Outparams.sNames 104 | 105 | Types = Outparams.Types 106 | 107 | 108 | EnumValues = 0 109 | 110 | End Function 111 | 112 | Function GetBinaryValue(hDefKey,sSubKeyName,sValueName, uValue ) 113 | Set Inparams = private_oRegSpecific.Methods_("GetBinaryValue").Inparameters 114 | 115 | Inparams.hDefKey = hDefKey 116 | 117 | Inparams.sSubKeyName = sSubKeyName 118 | 119 | Inparams.sValueName = sValueName 120 | 121 | set Outparams = private_oRegSpecific.ExecMethod_("GetBinaryValue", Inparams,,private_oCtx) 122 | 123 | uValue = Outparams.uValue 124 | 125 | 126 | GetBinaryValue = 0 127 | 128 | End Function 129 | 130 | Function GetDWORDValue(hDefKey,sSubKeyName,sValueName, uValue ) 131 | Set Inparams = private_oRegSpecific.Methods_("GetDWORDValue").Inparameters 132 | 133 | Inparams.hDefKey = hDefKey 134 | 135 | Inparams.sSubKeyName = sSubKeyName 136 | 137 | Inparams.sValueName = sValueName 138 | 139 | set Outparams = private_oRegSpecific.ExecMethod_("GetDWORDValue", Inparams,,private_oCtx) 140 | 141 | uValue = Outparams.uValue 142 | 143 | 144 | GetDWORDValue = 0 145 | 146 | End Function 147 | 148 | Function GetExpandedStringValue(hDefKey,sSubKeyName,sValueName, sValue ) 149 | Set Inparams = private_oRegSpecific.Methods_("GetExpandedStringValue").Inparameters 150 | 151 | Inparams.hDefKey = hDefKey 152 | 153 | Inparams.sSubKeyName = sSubKeyName 154 | 155 | Inparams.sValueName = sValueName 156 | 157 | set Outparams = private_oRegSpecific.ExecMethod_("GetExpandedStringValue", Inparams,,private_oCtx) 158 | 159 | sValue = Outparams.sValue 160 | 161 | 162 | GetExpandedStringValue = 0 163 | 164 | End Function 165 | 166 | Function GetMultiStringValue(hDefKey,sSubKeyName,sValueName, sValue ) 167 | Set Inparams = private_oRegSpecific.Methods_("GetMultiStringValue").Inparameters 168 | 169 | Inparams.hDefKey = hDefKey 170 | 171 | Inparams.sSubKeyName = sSubKeyName 172 | 173 | Inparams.sValueName = sValueName 174 | 175 | set Outparams = private_oRegSpecific.ExecMethod_("GetMultiStringValue", Inparams,,private_oCtx) 176 | 177 | sValue = Outparams.sValue 178 | 179 | 180 | GetMultiStringValue = 0 181 | 182 | End Function 183 | 184 | Function GetQWORDValue(hDefKey,sSubKeyName,sValueName, uValue ) 185 | Set Inparams = private_oRegSpecific.Methods_("GetQWORDValue").Inparameters 186 | 187 | Inparams.hDefKey = hDefKey 188 | 189 | Inparams.sSubKeyName = sSubKeyName 190 | 191 | Inparams.sValueName = sValueName 192 | 193 | set Outparams = private_oRegSpecific.ExecMethod_("GetQWORDValue", Inparams,,private_oCtx) 194 | 195 | uValue = Outparams.uValue 196 | 197 | 198 | GetQWORDValue = 0 199 | 200 | End Function 201 | 202 | Function GetSecurityDescriptor(hDefKey,sSubKeyName, Descriptor ) 203 | Set Inparams = private_oRegSpecific.Methods_("GetSecurityDescriptor").Inparameters 204 | 205 | Inparams.hDefKey = hDefKey 206 | 207 | Inparams.sSubKeyName = sSubKeyName 208 | 209 | set Outparams = private_oRegSpecific.ExecMethod_("GetSecurityDescriptor", Inparams,,private_oCtx) 210 | 211 | Descriptor = Outparams.Descriptor 212 | 213 | 214 | GetSecurityDescriptor = 0 215 | 216 | End Function 217 | 218 | Function GetStringValue(hDefKey,sSubKeyName,sValueName, sValue ) 219 | Set Inparams = private_oRegSpecific.Methods_("GetStringValue").Inparameters 220 | 221 | Inparams.hDefKey = hDefKey 222 | 223 | Inparams.sSubKeyName = sSubKeyName 224 | 225 | Inparams.sValueName = sValueName 226 | 227 | set Outparams = private_oRegSpecific.ExecMethod_("GetStringValue", Inparams,,private_oCtx) 228 | 229 | sValue = Outparams.sValue 230 | 231 | 232 | GetStringValue = 0 233 | 234 | End Function 235 | 236 | Function SetBinaryValue(hDefKey,sSubKeyName,sValueName,uValue) 237 | Set Inparams = private_oRegSpecific.Methods_("SetBinaryValue").Inparameters 238 | 239 | Inparams.hDefKey = hDefKey 240 | 241 | Inparams.sSubKeyName = sSubKeyName 242 | 243 | Inparams.sValueName = sValueName 244 | 245 | Inparams.uValue = uValue 246 | 247 | set Outparams = private_oRegSpecific.ExecMethod_("SetBinaryValue", Inparams,,private_oCtx) 248 | 249 | 250 | SetBinaryValue = 0 251 | 252 | End Function 253 | 254 | Function SetDWORDValue(hDefKey,sSubKeyName,sValueName,uValue) 255 | Set Inparams = private_oRegSpecific.Methods_("SetDWORDValue").Inparameters 256 | 257 | Inparams.hDefKey = hDefKey 258 | 259 | Inparams.sSubKeyName = sSubKeyName 260 | 261 | Inparams.sValueName = sValueName 262 | 263 | Inparams.uValue = uValue 264 | 265 | set Outparams = private_oRegSpecific.ExecMethod_("SetDWORDValue", Inparams,,private_oCtx) 266 | 267 | 268 | SetDWORDValue = 0 269 | 270 | End Function 271 | 272 | Function SetExpandedStringValue(hDefKey,sSubKeyName,sValueName,sValue) 273 | Set Inparams = private_oRegSpecific.Methods_("SetExpandedStringValue").Inparameters 274 | 275 | Inparams.hDefKey = hDefKey 276 | 277 | Inparams.sSubKeyName = sSubKeyName 278 | 279 | Inparams.sValueName = sValueName 280 | 281 | Inparams.sValue = sValue 282 | 283 | set Outparams = private_oRegSpecific.ExecMethod_("SetExpandedStringValue", Inparams,,private_oCtx) 284 | 285 | 286 | SetExpandedStringValue = 0 287 | 288 | End Function 289 | 290 | Function SetMultiStringValue(hDefKey,sSubKeyName,sValueName,sValue) 291 | Set Inparams = private_oRegSpecific.Methods_("SetMultiStringValue").Inparameters 292 | 293 | Inparams.hDefKey = hDefKey 294 | 295 | Inparams.sSubKeyName = sSubKeyName 296 | 297 | Inparams.sValueName = sValueName 298 | 299 | Inparams.sValue = sValue 300 | 301 | set Outparams = private_oRegSpecific.ExecMethod_("SetMultiStringValue", Inparams,,private_oCtx) 302 | 303 | 304 | SetMultiStringValue = 0 305 | 306 | End Function 307 | 308 | Function SetQWORDValue(hDefKey,sSubKeyName,sValueName,uValue) 309 | Set Inparams = private_oRegSpecific.Methods_("SetQWORDValue").Inparameters 310 | 311 | Inparams.hDefKey = hDefKey 312 | 313 | Inparams.sSubKeyName = sSubKeyName 314 | 315 | Inparams.sValueName = sValueName 316 | 317 | Inparams.uValue = uValue 318 | 319 | set Outparams = private_oRegSpecific.ExecMethod_("SetQWORDValue", Inparams,,private_oCtx) 320 | 321 | 322 | SetQWORDValue = 0 323 | 324 | End Function 325 | 326 | Function SetSecurityDescriptor(hDefKey,sSubKeyName,Descriptor) 327 | Set Inparams = private_oRegSpecific.Methods_("SetSecurityDescriptor").Inparameters 328 | 329 | Inparams.hDefKey = hDefKey 330 | 331 | Inparams.sSubKeyName = sSubKeyName 332 | 333 | Inparams.Descriptor = Descriptor 334 | 335 | set Outparams = private_oRegSpecific.ExecMethod_("SetSecurityDescriptor", Inparams,,private_oCtx) 336 | 337 | 338 | SetSecurityDescriptor = 0 339 | 340 | End Function 341 | 342 | Function SetStringValue(hDefKey,sSubKeyName,sValueName,sValue) 343 | Set Inparams = private_oRegSpecific.Methods_("SetStringValue").Inparameters 344 | 345 | Inparams.hDefKey = hDefKey 346 | 347 | Inparams.sSubKeyName = sSubKeyName 348 | 349 | Inparams.sValueName = sValueName 350 | 351 | Inparams.sValue = sValue 352 | 353 | set Outparams = private_oRegSpecific.ExecMethod_("SetStringValue", Inparams,,private_oCtx) 354 | 355 | 356 | SetStringValue = 0 357 | 358 | End Function 359 | -------------------------------------------------------------------------------- /vbs/regUtil.vbs: -------------------------------------------------------------------------------- 1 | ' TODO: consider incorporating a json writer of some sort instead of adhoc solution like the following 2 | ' e.g: http://demon.tw/my-work/vbs-json.html 3 | 4 | const HKEY_CLASSES_ROOT = &H80000000 5 | const HKEY_CURRENT_USER = &H80000001 6 | const HKEY_LOCAL_MACHINE = &H80000002 7 | const HKEY_USERS = &H80000003 8 | const HKEY_CURRENT_CONFIG = &H80000005 9 | 10 | Sub LoadRegistryImplementationByOSArchitecture() 11 | If IsNull(OSArchitecture) Then 12 | WriteLineErr "missing OSArchitecture global. did not call util.DetermineOSArchitecture? or Forgot to load util.vbs?" 13 | WScript.Quit 25125 14 | End If 15 | 16 | If OSArchitecture = "A" Then 17 | Include "ArchitectureAgnosticRegistry.vbs" 18 | Else 19 | Include "ArchitectureSpecificRegistry.vbs" 20 | End If 21 | End Sub 22 | 23 | Function PutValue(constHive, strSubKey, strValueName, strValue, strType) 24 | Select Case UCase(strType) 25 | 26 | Case "REG_SZ" 27 | PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue) 28 | 29 | Case "REG_EXPAND_SZ" 30 | PutValue = SetExpandedStringValue(constHive, strSubKey, strValueName, strValue) 31 | 32 | Case "REG_BINARY" 33 | PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue)) 34 | 35 | Case "REG_NONE" 36 | PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue)) 37 | 38 | ' TODO: need to check that indeed int is the right type here 39 | Case "REG_DWORD" 40 | PutValue = SetDWORDValue(constHive, strSubKey, strValueName, CDbl(strValue)) 41 | 42 | Case "REG_MULTI_SZ" 43 | PutValue = SetMultiStringValue(constHive, strSubKey, strValueName, Split(strValue, ",")) 44 | 45 | Case "REG_QWORD" 46 | PutValue = SetQWORDValue(constHive, strSubKey, strValueName, strValue) 47 | 48 | Case "REG_DEFAULT" 49 | PutValue = SetStringValue(constHive, strSubKey, "", strValue) 50 | 51 | Case Else 52 | PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue) 53 | 54 | End Select 55 | End Function 56 | 57 | ' render the child of a sub path strSubKey in hive constHive 58 | ' as json. 59 | Sub ListChildrenAsJson(constHive, strSubKey) 60 | ' start outputting json to stdout 61 | Write "{" 62 | 63 | Dim e1: e1 = EnumKey (constHive, strSubKey, arrKeyNames) 64 | If e1 <> 0 Then 65 | Write """exists"": false," 66 | Dim arrValueNames: arrValueNames = null 67 | Else 68 | Write """exists"": true," 69 | 70 | Dim e2: e2 = EnumValues (constHive, strSubKey, arrValueNames, arrValueTypes) 71 | If e2 <> 0 Then 72 | WScript.Quit e2 73 | End If 74 | End If 75 | 76 | Write """keys"": [" 77 | If Not IsNull(arrKeyNames) Then 78 | For x = 0 To UBound(arrKeyNames) 79 | If (x > 0) Then 80 | Write "," 81 | End If 82 | 83 | Write """" & JsonSafe(arrKeyNames(x)) & """" 84 | Next 85 | End If 86 | Write "]," 87 | ' TODO: some duplicity of code between the two paths of this condition, this needs to be address at some point 88 | Write """values"":{" 89 | If Not IsNull(arrValueNames) Then 90 | For y = 0 To UBound(arrValueNames) 91 | If y > 0 Then 92 | Write "," 93 | End If 94 | 95 | strValueName = arrValueNames(y) 96 | intValueType = arrValueTypes(y) 97 | 98 | ' assign the value to varValue 99 | GetValueByType constHive, strSubKey, strValueName, intValueType, varValue 100 | 101 | WriteValue strValueName, intValueType, varValue 102 | Next 103 | Else 104 | ' fix for keys with only default values in them 105 | ' see http://stackoverflow.com/questions/8840343/how-to-read-the-default-value-from-registry-in-vbscript 106 | GetStringValue constHive, strSubKey, "", strDefaultValue 107 | 108 | If IsNull(strDefaultValue) = false and strDefaultValue <> "" Then 109 | ' write the default value with REG_SZ 110 | WriteValue "", 1, strDefaultValue 111 | End If 112 | End If 113 | Write "}}" 114 | End Sub 115 | 116 | Sub WriteValue (strValueName, intValueType, varValue) 117 | Write """" 118 | Write JsonSafe(strValueName) 119 | Write """:{" 120 | Write """type"": """ 121 | Write RenderType(intValueType) 122 | Write """," 123 | Write """value"":" 124 | Write RenderValueByType(intValueType, varValue) 125 | Write "}" 126 | End Sub 127 | 128 | ' give a raw HKLM\something\somewhere 129 | ' output the hive constant and the subkey, in this case: 130 | ' HKEY_LOCAL_MACHINE will be assigned to outConstHive 131 | ' and something\somewhere will be assigned to outStrSubKey 132 | Sub ParseHiveAndSubKey(strRawKey, outConstHive, outStrSubKey) 133 | ' split into two parts to deduce the hive and the sub key 134 | arrSplitted = Split(strRawKey, "\", 2, 1) 135 | 136 | If UBound(arrSplitted) > 0 Then 137 | strHive = arrSplitted(0) 138 | outStrSubKey = arrSplitted(1) 139 | Else 140 | strHive = strRawKey 141 | outStrSubKey = "" 142 | End If 143 | 144 | outConstHive = StringToHiveConst(UCase(strHive)) 145 | End Sub 146 | 147 | Function ArrayRemoveAt(arr, pos) 148 | Dim i 149 | If IsArray(arr) Then 150 | If pos >= 0 And pos <= UBound(arr) Then 151 | For i = pos To UBound(arr) - 1 152 | arr(i) = arr(i + 1) 153 | Next 154 | ReDim Preserve arr(UBound(arr) - 1) 155 | End If 156 | End If 157 | End Function 158 | 159 | Sub ParseHiveAndSubKeyAndValue(strRawKey, outConstHive, outStrSubKey, outStrValue) 160 | ' split into two parts to deduce the hive and the sub key 161 | arrSplitted = Split(strRawKey, "\", -1, 1) 162 | 163 | If UBound(arrSplitted) > 0 Then 164 | strHive = arrSplitted(0) 165 | outStrValue = arrSplitted(UBound(arrSplitted)) 166 | test = ArrayRemoveAt(arrSplitted, UBound(arrSplitted)) 167 | test = ArrayRemoveAt(arrSplitted, 0) 168 | outStrSubKey = Join(arrSplitted, "\") 169 | Else 170 | strHive = strRawKey 171 | outStrSubKey = "" 172 | End If 173 | 174 | outConstHive = StringToHiveConst(UCase(strHive)) 175 | End Sub 176 | 177 | Function StringToHiveConst(strHive) 178 | 179 | Select Case strHive 180 | Case "HKCR" 181 | StringToHiveConst = HKEY_CLASSES_ROOT 182 | Case "HKCU" 183 | StringToHiveConst = HKEY_CURRENT_USER 184 | Case "HKLM" 185 | StringToHiveConst = HKEY_LOCAL_MACHINE 186 | Case "HKU" 187 | StringToHiveConst = HKEY_USERS 188 | Case "HKCC" 189 | StringToHiveConst = HKEY_CURRENT_CONFIG 190 | Case Else 191 | StringToHiveConst = Null 192 | End Select 193 | 194 | End Function 195 | 196 | ' TODO: this entire "by type" should be transformed into OOP style 197 | ' where each type will have a class with render(), getValue() etc... 198 | 199 | ' convert a value type number into a string label 200 | Function RenderType(intType) 201 | RenderType = "REG_UNKNOWN" 202 | 203 | Select Case intType 204 | Case 0 205 | RenderType = "REG_NONE" 206 | Case 1 207 | RenderType = "REG_SZ" 208 | Case 2 209 | RenderType = "REG_EXPAND_SZ" 210 | Case 3 211 | RenderType = "REG_BINARY" 212 | Case 4 213 | RenderType = "REG_DWORD" 214 | Case 7 215 | RenderType = "REG_MULTI_SZ" 216 | Case 11 217 | RenderType = "REG_QWORD" 218 | Case Else 219 | ' TODO: should report / throw an error here 220 | WriteErr("invalid Registry Value Type " & intType) 221 | 222 | End Select 223 | 224 | End Function 225 | 226 | ' render by value type: 227 | ' string will return as a string with double quotes, e.g "value" 228 | ' multi string values which return as an array ot strings "["1", "2"]" (double quotes included ofc) 229 | ' numeric values like DWORD and QWORD just return as the number e.g. 1 230 | ' byte arrays such as reg_binary return as an array of ints, e.g [1,2,3] 231 | Function RenderValueByType(intType, varValue) 232 | 233 | Select Case intType 234 | ' REG_NONE 235 | Case 0 236 | RenderValueByType = "0" 237 | 238 | ' REG_SZ 239 | Case 1 240 | RenderValueByType = """" & JsonSafe(varValue) & """" 241 | 242 | ' REG_EXPAND_SZ 243 | Case 2 244 | RenderValueByType = """" & JsonSafe(varValue) & """" 245 | 246 | ' REG_BINARY 247 | Case 3 248 | RenderValueByType = RenderByteArray(varValue) 249 | 250 | ' REG_DWORD 251 | Case 4 252 | RenderValueByType= varValue 253 | 254 | ' REG_MULYI_SZ' 255 | Case 7 256 | 257 | RenderValueByType = RenderStringArray(varValue) 258 | ' REG_QWORD 259 | Case 11 260 | RenderValueByType = varValue 261 | Case Else 262 | ' TODO: should report / throw an error here 263 | WriteErr("invalid Registry Value Type " & intType) 264 | End Select 265 | 266 | End Function 267 | 268 | ' get the value of a registry based on its value type and assign it to out parameter outVarValue 269 | Sub GetValueByType(constHive, strKey, strValueName, intType, outVarValue) 270 | 271 | Select Case intType 272 | ' REG_NONE 273 | Case 0 274 | GetStringValue constHive, strKey, strValueName, "0" 275 | Exit Sub 276 | 277 | ' REG_SZ 278 | Case 1 279 | GetStringValue constHive, strKey, strValueName, outVarValue 280 | Exit Sub 281 | 282 | ' REG_EXPAND_SZ 283 | Case 2 284 | GetExpandedStringValue constHive, strKey, strValueName, outVarValue 285 | Exit Sub 286 | 287 | ' REG_BINARY 288 | Case 3 289 | GetBinaryValue constHive, strKey, strValueName, outVarValue 290 | Exit Sub 291 | 292 | ' REG_DWORD 293 | Case 4 294 | GetDWORDValue constHive, strKey, strValueName, outVarValue 295 | 296 | ' #21 - VBS does not support UInt32. This is the workaround 297 | If outVarValue < 0 Then outVarValue = 4294967296 + outVarValue 298 | 299 | Exit Sub 300 | 301 | ' REG_MULYI_SZ' 302 | Case 7 303 | GetMultiStringValue constHive, strKey, strValueName, outVarValue 304 | Exit Sub 305 | 306 | ' REG_QWORD 307 | Case 11 308 | GetQWORDValue constHive, strKey, strValueName, outVarValue 309 | Exit Sub 310 | 311 | Case Else 312 | ' TODO: should report / throw an error here 313 | WriteErr("invalid Registry Value Type " & intType) 314 | End Select 315 | 316 | End Sub 317 | 318 | ' render a byte array as a json array of numbers 319 | Function RenderByteArray(arr) 320 | RenderByteArray = "[]" 321 | 322 | If Not IsNull(arr) Then 323 | RenderByteArray = "[" & Join(arr, ",") & "]" 324 | End If 325 | End Function 326 | 327 | ' render a string array as json string array 328 | Function RenderStringArray(arr) 329 | Result = "[" 330 | If Not IsNull(arr) Then 331 | For t = 0 To UBound(arr) 332 | If (t > 0) Then 333 | Result = Result & "," 334 | End If 335 | 336 | Result = Result & """" & JsonSafe(arr(t)) & """" 337 | Next 338 | End If 339 | Result = Result & "]" 340 | 341 | RenderStringArray = Result 342 | End Function 343 | 344 | Function ToBinaryValue(strValue) 345 | 346 | arrValue = Split(strValue, ",") 347 | 348 | If IsNull(arrValue) Then 349 | ToBinaryValue = Array() 350 | Exit Function 351 | End If 352 | 353 | For i = 0 To UBound(arrValue) 354 | arrValue(i) = CInt(arrValue(i)) 355 | Next 356 | 357 | ToBinaryValue = arrValue 358 | End Function -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # regedit 2 | Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host. 3 | 4 | No pesky native code :-) 5 | 6 | ## Install 7 | 8 | ``` 9 | npm install regedit 10 | ``` 11 | 12 | ## Example 13 | ```javascript 14 | const regedit = require('regedit').promisified 15 | 16 | async function main() { 17 | const listResult = await regedit.list('HKCU\\SOFTWARE') 18 | console.log(listResult) 19 | 20 | await regedit.createKey(['HKLM\\SOFTWARE\\MyApp2', 'HKCU\\SOFTWARE\\MyApp']) 21 | await regedit.putValue({ 22 | 'HKCU\\SOFTWARE\\MyApp': { 23 | Company: { 24 | value: 'Moo corp', 25 | type: 'REG_SZ' 26 | } 27 | }, 28 | 'HKLM\\SOFTWARE\\MyApp2': { 29 | test: { 30 | value: '123', 31 | type: 'REG_SZ' 32 | } 33 | } 34 | }) 35 | } 36 | 37 | main() 38 | 39 | ``` 40 | #### Friendly warning regarding 32bit and 64bit OS / Process 41 | 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](#regeditarchlist32stringarray-function) methods were added. 42 | 43 | Further reading [here](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724072%28v=vs.85%29.aspx) 44 | 45 | #### A note about Electron 46 | This software uses Windows Script Host to read and write to the registry. For that purpose, it will execute [`.wsf`](https://github.com/kessler/node-regedit/tree/master/vbs) 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)`: 47 | 48 | ```js 49 | // Assuming the files lie in /resources/my-location 50 | const vbsDirectory = path.join(path.dirname(electron.remote.app.getPath('exe')), './resources/my-location'); 51 | regedit.setExternalVBSLocation(vbsDirectory); 52 | ``` 53 | 54 | Also, take a look at [#60](https://github.com/kessler/node-regedit/issues/60) 55 | 56 | #### Promise based API 57 | regedit was originally written using callbacks, but a promise based API was added later: 58 | 59 | ```js 60 | // callback api 61 | const regedit = require('regedit') 62 | // promise api 63 | const promisifiedRegedit = require('regedit').promisified 64 | ``` 65 | 66 | # API 67 | Every command executes a sub process that runs vbscript code. To boost efficiency, every command supports batching. 68 | 69 | ## Reading keys and values 70 | 71 | ### regedit.list([String|Array], [Function]) 72 | 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. 73 | 74 | Given the command: 75 | ```javascript 76 | regedit.list(['HKCU\\SOFTWARE', 'HKLM\\SOFTWARE', 'HKCU\\IM_FAKE_THEREFOR_I_DONT_EXIST'], function(err, result) { 77 | ... 78 | }) 79 | ``` 80 | 81 | *Result* will be an object with the following structure: 82 | ```javascript 83 | { 84 | 'HKCU\\SOFTWARE': { 85 | exists: true, 86 | keys: [ 'Google', 'Microsoft', ... more direct sub keys ] 87 | values: { 88 | 'valueName': { 89 | value: '123', 90 | type: 'REG_SZ' 91 | } 92 | ... more direct child values of HKCU\\SOFTWARE 93 | } 94 | }, 95 | 'HKLM\\SOFTWARE': { 96 | exists: true, 97 | keys: [ 'Google', 'Microsoft', ... more direct sub keys ] 98 | values: { 99 | 'valueName': { 100 | value: '123', 101 | type: 'REG_SZ' 102 | } 103 | ... more direct child values of HKLM\\SOFTWARE 104 | } 105 | }, 106 | 'HKCU\\IM_FAKE_THEREFOR_I_DONT_EXIST': { 107 | exists: false, 108 | keys: [], 109 | values: {} 110 | } 111 | } 112 | ``` 113 | 114 | ##### Note about listing default values 115 | In the windows registry a key may have a default value. When enumarting value names, the default value's name will be empty. 116 | 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. 117 | 118 | Thus, accessing the default value becomes slightly awkward: 119 | ```javascript 120 | regedit.list('path\\to\\default\\value', function (err, result) { 121 | var defaultValue = result['path\\to\\default\\value'].values[''].value 122 | }) 123 | ``` 124 | 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. 125 | 126 | ***list with callback api will be deperecated and eventually removed in future versions, take a look at the streaming interface below*** 127 | 128 | ### regedit.list([String|Array]) - streaming interface 129 | 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. Using the streaming interface is also important when trying to fetch a large amount of keys from the registry, as it overcomes the limitation of passing data as a command line argument. 130 | 131 | **This operation will mutate the keys array** 132 | 133 | Example: 134 | ```javascript 135 | regedit.list(['HKCU\\SOFTWARE', 'HKLM\\SOFTWARE']) 136 | .on('data', function(entry) { 137 | console.log(entry.key) 138 | console.log(entry.data) 139 | }) 140 | .on('finish', function () { 141 | console.log('list operation finished') 142 | }) 143 | ``` 144 | This code output will look like this: 145 | ``` 146 | HKCU\\SOFTWARE 147 | { 148 | keys: [ 'Google', 'Microsoft', ... more direct sub keys ] 149 | values: { 150 | 'valueName': { 151 | value: '123', 152 | type: 'REG_SZ' 153 | } 154 | ... more direct child values of HKCU\\SOFTWARE 155 | } 156 | } 157 | HKLM\\SOFTWARE 158 | { 159 | keys: [ 'Google', 'Microsoft', ... more direct sub keys ] 160 | values: { 161 | 'valueName': { 162 | value: '123', 163 | type: 'REG_SZ' 164 | } 165 | ... more direct child values of HKLM\\SOFTWARE 166 | } 167 | } 168 | ``` 169 | 170 | #### regedit.arch.list32([String|Array], [Function]) 171 | same as *regedit.list([String|Array], [Function])*, only force a 32bit architecture on the registry 172 | 173 | #### regedit.arch.list32([String|Array]) 174 | streaming interface, see *regedit.list([String|Array])* 175 | 176 | #### regedit.arch.list64([String|Array], [Function]) 177 | same as list, only force a 64bit architecture on the registry 178 | 179 | #### regedit.arch.list64([String|Array]) 180 | streaming interface, see *regedit.list([String|Array])* 181 | 182 | #### regedit.arch.list([String|Array], [Function]) 183 | same as list, only force your system architecture on the registry (select automatically between list64 and list32) 184 | 185 | #### regedit.arch.list([String|Array]) 186 | streaming interface, see *regedit.list([String|Array])* 187 | 188 | ### regedit.listUnexpandedValues([String|Array], [function]) 189 | Lists the values of one or more _value keys_ (or paths as I like to call them) without expanding any embedded environment variables. 190 | Specify an array instead of a string to query multiple keys in the same run. 191 | 192 | Read issue [#40](https://github.com/kessler/node-regedit/issues/40) on why and when this is needed. 193 | 194 | Unlike the rest of this project, which is based on StdRegServ, this API (added on May 2022) uses a wshell object RegRead method. Although it's properly tested, please report any issues asap. 195 | 196 | ```js 197 | const regedit = require('./index').promisified 198 | 199 | async function main() { 200 | const res = await regedit.listUnexpandedValues('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData') 201 | 202 | console.log(JSON.stringify(res, null, '\t')) 203 | } 204 | 205 | main() 206 | ``` 207 | 208 | *Result* will look like this: 209 | ```json 210 | [ 211 | { 212 | "path": "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData", 213 | "exists": true, 214 | "value": "%USERPROFILE%\\AppData\\Roaming" 215 | } 216 | ] 217 | ``` 218 | This API also support a streaming interface much like `list` does. 219 | 220 | ## Manipulating the registry 221 | ### regedit.createKey([String|Array], [Function]) 222 | Creates one or more keys in the registry 223 | **This operation will mutate the keys array** 224 | 225 | ### regedit.deleteKey([String|Array], [Function]) 226 | Deletes one or more keys in the registry 227 | **This operation will mutate the keys array** 228 | 229 | ### regedit.putValue(Object, Function) 230 | Put one or more values in the registry. The Object given to this function is almost identical to the result of regedit.list(). 231 | 232 | Here is an example: 233 | ```javascript 234 | var valuesToPut = { 235 | 'HKCU\\Software\\MySoftware': { 236 | 'myValue1': { 237 | value: [1,2,3], 238 | type: 'REG_BINARY' 239 | }, 240 | 'myValue2': { 241 | value: 'aString', 242 | type: 'REG_SZ' 243 | } 244 | }, 245 | 'HKCU\\Software\\MySoftware\\foo': { 246 | 'myValue3': { 247 | value: ['a', 'b', 'c'] 248 | type: 'REG_MULTI_SZ' 249 | } 250 | } 251 | } 252 | 253 | regedit.putValue(valuesToPut, function(err) { 254 | 255 | }) 256 | ``` 257 | Supported value types are: 258 | - REG_SZ, REG_EXPAND_SZ: a string basically 259 | - REG_DWORD, REG_QWORD: should use javascript numbers 260 | - REG_MULTI_SZ: an array of strings 261 | - REG_BINARY: an array of numbers (representing bytes) 262 | - REG_DEFAULT: see note about default values below 263 | 264 | ##### Note about setting default values 265 | 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 266 | 267 | this is a temporary solution and is subject to change in future versions 268 | ```javascript 269 | var values = { 270 | 'HKCU\\Software\\MySoftware': { 271 | 'someNameIDontCareAbout': { 272 | value: 'Must be a string', 273 | type: 'REG_DEFAULT' 274 | }, 275 | 'myValue2': { 276 | value: 'aString', 277 | type: 'REG_SZ' 278 | } 279 | } 280 | } 281 | regedit.putValue(values, function (err) { 282 | }) 283 | ``` 284 | 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. 285 | 286 | ### regedit.deleteValue([String|Array], [Function]) 287 | Deletes one or more values in the registry 288 | **This operation will mutate the keys array** 289 | 290 | ## Promises 291 | To use promises access the function you want through `regedit.promisified`, all function signatures are the same `([String|Array], [Arch (optional)])` 292 | 293 | Default arch is agnostic. 294 | 295 | ### Example: regedit.promisified.list([String|Array], [Arch (optional)]) 296 | ```javascript 297 | try { 298 | const registryList = await regedit.promisified.list(['HKCU\\SOFTWARE', 'HKLM\\SOFTWARE', 'HKCU\\IM_FAKE_THEREFOR_I_DONT_EXIST']) 299 | } catch (e) { 300 | console.log('Error while listing keys:', e.message) 301 | } 302 | ``` 303 | Result and errors should be the same as not promisified. 304 | 305 | 306 | ## Develop 307 | 308 | ### Run tests 309 | ``` 310 | mocha -R spec 311 | ``` 312 | 313 | ### Enable debug output 314 | ``` 315 | set DEBUG=regedit 316 | ``` 317 | 318 | ## TODO 319 | None :) 320 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const childProcess = require('child_process') 3 | const path = require('path') 4 | const debug = require('debug')('regedit') 5 | const errors = require('./errors.js') 6 | const StreamSlicer = require('stream-slicer') 7 | const through2 = require('through2') 8 | const helper = require('./lib/helper.js') 9 | const execFile = require('./lib/execFile.js')() 10 | const cscript = require('./lib/cscript.js') 11 | 12 | /* 13 | * Access the registry without using a specific os architecture, this means that on a 32bit process on a 64bit machine 14 | * when we access hklm\software we will actually be accessing hklm\software\wow6432node. 15 | */ 16 | const OS_ARCH_AGNOSTIC = 'A' 17 | 18 | /* 19 | * Access the registry using a specific os architecture, but determine what the architecture is automatically 20 | * This means that accessing in order to access the 32bit software registry on a 64bit machine we will need to 21 | * use the key hklm\software\wow6432node 22 | */ 23 | const OS_ARCH_SPECIFIC = 'S' 24 | 25 | /* 26 | * Access the registry using 32bit os architecture 27 | */ 28 | const OS_ARCH_32BIT = '32' 29 | 30 | /* 31 | * Access the registry using 64bit os architecture, this will have no effect on 32bit process/machines 32 | */ 33 | const OS_ARCH_64BIT = '64' 34 | 35 | /* 36 | * If this value is set the module will change directory of the VBS to the appropriate location instead of the local VBS folder 37 | */ 38 | let externalVBSFolderLocation 39 | 40 | function handleErrorsAndClose(child, callback) { 41 | let error 42 | child.once('error', function(e) { 43 | debug('process error %s', e) 44 | error = e 45 | }) 46 | 47 | child.once('close', function(code) { 48 | debug('process exit with code %d', code) 49 | 50 | if (error) { 51 | if (error.code in errors) { 52 | return callback(errors[error.code]) 53 | } 54 | return callback(error) 55 | 56 | } 57 | 58 | if (code !== 0) { 59 | if (code in errors) { 60 | return callback(errors[code]) 61 | } 62 | return callback(new Error('vbscript process reported unknown error code ' + code)) 63 | 64 | } 65 | 66 | callback() 67 | }) 68 | } 69 | 70 | function execute(args, callback) { 71 | if (typeof callback !== 'function') { 72 | throw new Error('missing callback') 73 | } 74 | 75 | debug(args) 76 | 77 | cscript.init(function(err) { 78 | if (err) { 79 | return callback(err) 80 | } 81 | 82 | childProcess.execFile(cscript.path(), args, function(err, stdout, stderr) { 83 | 84 | if (err) { 85 | if (stdout) { 86 | console.log(stdout) 87 | } 88 | 89 | if (stderr) { 90 | console.error(stderr) 91 | } 92 | 93 | if (err.code in errors) { 94 | return callback(errors[err.code]) 95 | } 96 | return callback(err) 97 | 98 | } 99 | 100 | // in case we have stuff in stderr but no real error 101 | if (stderr) { 102 | return callback(new Error(stderr)) 103 | } 104 | if (!stdout) { 105 | return callback() 106 | } 107 | 108 | debug(stdout) 109 | 110 | let result 111 | err = null 112 | 113 | try { 114 | result = JSON.parse(stdout) 115 | } catch (e) { 116 | e.stdout = stdout 117 | err = e 118 | } 119 | 120 | callback(err, result) 121 | }) 122 | }) 123 | } 124 | 125 | function spawnEx(args, keys, callback) { 126 | cscript.init(function(err) { 127 | if (err) { 128 | return callback(err) 129 | } 130 | 131 | debug(args) 132 | 133 | const child = execFile(cscript.path(), args, { encoding: 'utf8' }) 134 | 135 | handleErrorsAndClose(child, callback) 136 | 137 | helper.writeArrayToStream(keys, child.stdin) 138 | }) 139 | } 140 | 141 | //TODO: move to helper.js? 142 | function renderValueByType(value, type) { 143 | type = type.toUpperCase() 144 | 145 | switch (type) { 146 | case 'REG_NONE': 147 | if (value === '') { 148 | return '\0' 149 | } 150 | return value 151 | 152 | case 'REG_BINARY': 153 | if (!Array.isArray(value)) { 154 | throw new Error('invalid value type ' + typeof(value) + ' for registry type REG_BINARY, please use an array of numbers') 155 | } 156 | return value.join(',') 157 | 158 | case 'REG_MULTI_SZ': 159 | if (!Array.isArray(value)) { 160 | throw new Error('invalid value type ' + typeof(value) + ' for registry type REG_BINARY, please use an array of strings') 161 | } 162 | return value.join(',') 163 | 164 | case 'REG_SZ': 165 | if (value === '') { 166 | return '\0' 167 | } 168 | return value 169 | 170 | default: 171 | return value 172 | } 173 | } 174 | 175 | //TODO: move to helper.js? 176 | function baseCommand(cmd, arch) { 177 | let scriptPath 178 | 179 | // test undefined, null and empty string 180 | if (externalVBSFolderLocation && typeof(externalVBSFolderLocation) === 'string') { 181 | scriptPath = externalVBSFolderLocation 182 | } else { 183 | scriptPath = path.join(__dirname, 'vbs') 184 | } 185 | 186 | return ['//Nologo', path.join(scriptPath, cmd), arch] 187 | } 188 | 189 | //TODO: move to helper.js? 190 | function toCommandArgs(cmd, arch, keys) { 191 | let result = baseCommand(cmd, arch) 192 | if (typeof keys === 'string') { 193 | result.push(keys) 194 | } else if (Array.isArray(keys)) { 195 | result = result.concat(keys) 196 | } else { 197 | debug('creating command without using keys %s', keys ? keys : '') 198 | } 199 | 200 | return result 201 | } 202 | 203 | module.exports.setExternalVBSLocation = function(newLocation) { 204 | if (fs.existsSync(newLocation)) { 205 | externalVBSFolderLocation = newLocation 206 | return 'Folder found and set' 207 | } 208 | 209 | return 'Folder not found' 210 | } 211 | 212 | module.exports.list = function(keys, architecture, callback) { 213 | //console.log('list with callback will be deprecated in future versions, use list streaming interface') 214 | 215 | if (architecture === undefined) { 216 | callback = undefined 217 | architecture = OS_ARCH_AGNOSTIC 218 | } else if (typeof architecture === 'function') { 219 | callback = architecture 220 | architecture = OS_ARCH_AGNOSTIC 221 | } 222 | 223 | if (typeof keys === 'string') { 224 | keys = [keys] 225 | } 226 | 227 | if (typeof callback === 'function') { 228 | execute(toCommandArgs('regList.wsf', architecture, keys), callback) 229 | return 230 | } 231 | 232 | const outputStream = through2.obj(helper.vbsOutputTransform) 233 | 234 | cscript.init(function(err) { 235 | if (err) { 236 | return outputStream.emit('error', err) 237 | } 238 | 239 | const args = baseCommand('regListStream.wsf', architecture) 240 | 241 | const child = execFile(cscript.path(), args, { encoding: 'utf8' }, function(err) { 242 | if (err) { 243 | outputStream.emit('error', err) 244 | } 245 | }) 246 | 247 | child.stderr.pipe(process.stderr) 248 | 249 | const slicer = new StreamSlicer({ sliceBy: helper.WIN_EOL }) 250 | 251 | child.stdout.pipe(slicer).pipe(outputStream) 252 | 253 | helper.writeArrayToStream(keys, child.stdin) 254 | }) 255 | 256 | return outputStream 257 | } 258 | 259 | module.exports.createKey = function(keys, architecture, callback) { 260 | if (typeof architecture === 'function') { 261 | callback = architecture 262 | architecture = OS_ARCH_AGNOSTIC 263 | } 264 | 265 | if (typeof keys === 'string') { 266 | keys = [keys] 267 | } 268 | 269 | const args = baseCommand('regCreateKey.wsf', architecture) 270 | 271 | spawnEx(args, keys, callback) 272 | } 273 | 274 | module.exports.deleteKey = function(keys, architecture, callback) { 275 | if (typeof architecture === 'function') { 276 | callback = architecture 277 | architecture = OS_ARCH_AGNOSTIC 278 | } 279 | 280 | if (typeof keys === 'string') { 281 | keys = [keys] 282 | } 283 | 284 | const args = baseCommand('regDeleteKey.wsf', architecture) 285 | 286 | spawnEx(args, keys, callback) 287 | } 288 | 289 | module.exports.deleteValue = function(keys, architecture, callback) { 290 | if (typeof architecture === 'function') { 291 | callback = architecture 292 | architecture = OS_ARCH_AGNOSTIC 293 | } 294 | 295 | if (typeof keys === 'string') { 296 | keys = [keys] 297 | } 298 | 299 | var args = baseCommand('regDeleteValue.wsf', architecture) 300 | 301 | spawnEx(args, keys, callback) 302 | } 303 | 304 | module.exports.putValue = function(map, architecture, callback) { 305 | if (typeof architecture === 'function') { 306 | callback = architecture 307 | architecture = OS_ARCH_AGNOSTIC 308 | } 309 | 310 | const args = baseCommand('regPutValue.wsf', architecture) 311 | 312 | let values = [] 313 | 314 | for (const key in map) { 315 | if (map.hasOwnProperty(key)) { 316 | const keyValues = map[key] 317 | 318 | for (const valueName in keyValues) { 319 | if (keyValues.hasOwnProperty(valueName)) { 320 | const entry = keyValues[valueName] 321 | 322 | // helper writes the array to the stream in reversed order 323 | values.push(entry.type) 324 | values.push(renderValueByType(entry.value, entry.type)) 325 | values.push(valueName) 326 | values.push(key) 327 | } 328 | } 329 | } 330 | } 331 | 332 | spawnEx(args, values, callback) 333 | } 334 | 335 | module.exports.listUnexpandedValues = function(valuePaths, architecture, callback) { 336 | if (architecture === undefined) { 337 | callback = undefined 338 | architecture = OS_ARCH_AGNOSTIC 339 | } else if (typeof architecture === 'function') { 340 | callback = architecture 341 | architecture = OS_ARCH_AGNOSTIC 342 | } 343 | 344 | if (typeof valuePaths === 'string') { 345 | valuePaths = [valuePaths] 346 | } 347 | 348 | if (typeof callback === 'function') { 349 | execute(toCommandArgs('wsRegReadList.wsf', architecture, valuePaths), callback) 350 | return 351 | } 352 | 353 | const outputStream = through2.obj(helper.vbsOutputTransform) 354 | 355 | cscript.init(function(err) { 356 | if (err) { 357 | return outputStream.emit('error', err) 358 | } 359 | 360 | const args = baseCommand('wsRegReadListStream.wsf', architecture) 361 | 362 | const child = execFile(cscript.path(), args, { encoding: 'utf8' }, function(err) { 363 | if (err) { 364 | outputStream.emit('error', err) 365 | } 366 | }) 367 | 368 | child.stderr.pipe(process.stderr) 369 | 370 | const slicer = new StreamSlicer({ sliceBy: helper.WIN_EOL }) 371 | 372 | child.stdout.pipe(slicer).pipe(outputStream) 373 | 374 | helper.writeArrayToStream(valuePaths, child.stdin) 375 | }) 376 | 377 | return outputStream 378 | } 379 | 380 | module.exports.promisified = { 381 | list: function(keys, architecture = OS_ARCH_AGNOSTIC) { 382 | return new Promise(function(resolve, reject) { 383 | module.exports.list(keys, architecture, function(err, res) { 384 | if (err) { 385 | return reject(err) 386 | } 387 | return resolve(res) 388 | }) 389 | }) 390 | }, 391 | listUnexpandedValues: function(valuePaths, architecture = OS_ARCH_AGNOSTIC) { 392 | return new Promise(function(resolve, reject) { 393 | module.exports.listUnexpandedValues(valuePaths, architecture, function(err, res) { 394 | if (err) { 395 | return reject(err) 396 | } 397 | return resolve(res) 398 | }) 399 | }) 400 | }, 401 | createKey: function(keys, architecture = OS_ARCH_AGNOSTIC) { 402 | return new Promise(function(resolve, reject) { 403 | module.exports.createKey(keys, architecture, function(err) { 404 | if (err) { 405 | return reject(err) 406 | } 407 | return resolve() 408 | }) 409 | }) 410 | }, 411 | deleteKey: function(keys, architecture = OS_ARCH_AGNOSTIC) { 412 | return new Promise(function(resolve, reject) { 413 | module.exports.deleteKey(keys, architecture, function(err) { 414 | if (err) { 415 | return reject(err) 416 | } 417 | return resolve() 418 | }) 419 | }) 420 | }, 421 | deleteValue: function(keys, architecture = OS_ARCH_AGNOSTIC) { 422 | return new Promise(function(resolve, reject) { 423 | module.exports.deleteValue(keys, architecture, function(err) { 424 | if (err) { 425 | return reject(err) 426 | } 427 | return resolve() 428 | }) 429 | }) 430 | }, 431 | putValue: function(map, architecture = OS_ARCH_AGNOSTIC) { 432 | return new Promise(function(resolve, reject) { 433 | module.exports.putValue(map, architecture, function(err) { 434 | if (err) { 435 | return reject(err) 436 | } 437 | return resolve() 438 | }) 439 | }) 440 | }, 441 | } 442 | 443 | module.exports.arch = {} 444 | 445 | module.exports.arch.list = function(keys, callback) { 446 | return module.exports.list(keys, OS_ARCH_SPECIFIC, callback) 447 | } 448 | 449 | module.exports.arch.list32 = function(keys, callback) { 450 | return module.exports.list(keys, OS_ARCH_32BIT, callback) 451 | } 452 | 453 | module.exports.arch.list64 = function(keys, callback) { 454 | return module.exports.list(keys, OS_ARCH_64BIT, callback) 455 | } 456 | 457 | module.exports.arch.listUnexpandedValues = function(valuePaths, callback) { 458 | return module.exports.listUnexpandedValues(valuePaths, OS_ARCH_SPECIFIC, callback) 459 | } 460 | 461 | module.exports.arch.listUnexpandedValues32 = function(valuePaths, callback) { 462 | return module.exports.listUnexpandedValues(valuePaths, OS_ARCH_32BIT, callback) 463 | } 464 | 465 | module.exports.arch.listUnexpandedValues64 = function(valuePaths, callback) { 466 | return module.exports.listUnexpandedValues(valuePaths, OS_ARCH_64BIT, callback) 467 | } 468 | 469 | module.exports.arch.createKey = function(keys, callback) { 470 | return module.exports.createKey(keys, OS_ARCH_SPECIFIC, callback) 471 | } 472 | 473 | module.exports.arch.createKey32 = function(keys, callback) { 474 | return module.exports.createKey(keys, OS_ARCH_32BIT, callback) 475 | } 476 | 477 | module.exports.arch.createKey64 = function(keys, callback) { 478 | return module.exports.createKey(keys, OS_ARCH_64BIT, callback) 479 | } 480 | 481 | module.exports.arch.deleteKey = function(keys, callback) { 482 | return module.exports.deleteKey(keys, OS_ARCH_SPECIFIC, callback) 483 | } 484 | 485 | module.exports.arch.deleteKey32 = function(keys, callback) { 486 | return module.exports.deleteKey(keys, OS_ARCH_32BIT, callback) 487 | } 488 | 489 | module.exports.arch.deleteKey64 = function(keys, callback) { 490 | return module.exports.deleteKey(keys, OS_ARCH_64BIT, callback) 491 | } 492 | 493 | module.exports.arch.deleteValue = function(keys, callback) { 494 | return module.exports.deleteValue(keys, OS_ARCH_SPECIFIC, callback) 495 | } 496 | 497 | module.exports.arch.deleteValue32 = function(keys, callback) { 498 | return module.exports.deleteValue(keys, OS_ARCH_32BIT, callback) 499 | } 500 | 501 | module.exports.arch.deleteValue64 = function(keys, callback) { 502 | return module.exports.deleteValue(keys, OS_ARCH_64BIT, callback) 503 | } 504 | 505 | module.exports.arch.putValue = function(keys, callback) { 506 | return module.exports.putValue(keys, OS_ARCH_SPECIFIC, callback) 507 | } 508 | 509 | module.exports.arch.putValue32 = function(keys, callback) { 510 | return module.exports.putValue(keys, OS_ARCH_32BIT, callback) 511 | } 512 | 513 | module.exports.arch.putValue64 = function(keys, callback) { 514 | return module.exports.putValue(keys, OS_ARCH_64BIT, callback) 515 | } 516 | 517 | module.exports.arch.promisified = { 518 | list: function(keys) { 519 | return module.exports.promisified.list(keys, OS_ARCH_SPECIFIC) 520 | }, 521 | list32: function(keys) { 522 | return module.exports.promisified.list(keys, OS_ARCH_32BIT) 523 | }, 524 | list64: function(keys) { 525 | return module.exports.promisified.list(keys, OS_ARCH_64BIT) 526 | }, 527 | listUnexpandedValues: function(valuePaths) { 528 | return module.exports.promisified.listUnexpandedValues(valuePaths, OS_ARCH_SPECIFIC) 529 | }, 530 | listUnexpandedValues32: function(valuePaths) { 531 | return module.exports.promisified.listUnexpandedValues(valuePaths, OS_ARCH_32BIT) 532 | }, 533 | listUnexpandedValues64: function(valuePaths) { 534 | return module.exports.promisified.listUnexpandedValues(valuePaths, OS_ARCH_64BIT) 535 | }, 536 | createKey: function(keys) { 537 | return module.exports.promisified.createKey(keys, OS_ARCH_SPECIFIC) 538 | }, 539 | createKey32: function(keys) { 540 | return module.exports.promisified.createKey(keys, OS_ARCH_32BIT) 541 | }, 542 | createKey64: function(keys) { 543 | return module.exports.promisified.createKey(keys, OS_ARCH_64BIT) 544 | }, 545 | deleteKey: function(keys) { 546 | return module.exports.promisified.deleteKey(keys, OS_ARCH_SPECIFIC) 547 | }, 548 | deleteKey32: function(keys) { 549 | return module.exports.promisified.deleteKey(keys, OS_ARCH_32BIT) 550 | }, 551 | deleteKey64: function(keys) { 552 | return module.exports.promisified.deleteKey(keys, OS_ARCH_64BIT) 553 | }, 554 | deleteValue: function(keys) { 555 | return module.exports.promisified.deleteValue(keys, OS_ARCH_SPECIFIC) 556 | }, 557 | deleteValue32: function(keys) { 558 | return module.exports.promisified.deleteValue(keys, OS_ARCH_32BIT) 559 | }, 560 | deleteValue64: function(keys) { 561 | return module.exports.promisified.deleteValue(keys, OS_ARCH_64BIT) 562 | }, 563 | putValue: function(keys) { 564 | return module.exports.promisified.putValue(keys, OS_ARCH_SPECIFIC) 565 | }, 566 | putValue32: function(keys) { 567 | return module.exports.promisified.putValue(keys, OS_ARCH_32BIT) 568 | }, 569 | putValue64: function(keys) { 570 | return module.exports.promisified.putValue(keys, OS_ARCH_64BIT) 571 | }, 572 | } 573 | -------------------------------------------------------------------------------- /winerrors/parsed.json: -------------------------------------------------------------------------------- 1 | [{"error":"wbemErrFailed","code":2147749889,"description":"The call failed."},{"error":"wbemErrNotFound","code":2147749890,"description":"The object could not be found."},{"error":"wbemErrAccessDenied","code":2147749891,"description":"The current user does not have permission to perform the action."},{"error":"wbemErrProviderFailure","code":2147749892,"description":"The provider has failed at some time other than during initialization."},{"error":"wbemErrTypeMismatch","code":2147749893,"description":"A type mismatch occurred."},{"error":"wbemErrOutOfMemory","code":2147749894,"description":"There was not enough memory for the operation."},{"error":"wbemErrInvalidContext","code":2147749895,"description":"The SWbemNamedValue object is not valid."},{"error":"wbemErrInvalidParameter","code":2147749896,"description":"One of the parameters to the call is not correct."},{"error":"wbemErrNotAvailable","code":2147749897,"description":"The resource, typically a remote server, is not currently available."},{"error":"wbemErrCriticalError","code":2147749898,"description":"An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support."},{"error":"wbemErrInvalidStream","code":2147749899,"description":"One or more network packets were corrupted during a remote session."},{"error":"wbemErrNotSupported","code":2147749900,"description":"The feature or operation is not supported."},{"error":"wbemErrInvalidSuperclass","code":2147749901,"description":"The parent class specified is not valid."},{"error":"wbemErrInvalidNamespace","code":2147749902,"description":"The namespace specified could not be found."},{"error":"wbemErrInvalidObject","code":2147749903,"description":"The specified instance is not valid."},{"error":"wbemErrInvalidClass","code":2147749904,"description":"The specified class is not valid."},{"error":"wbemErrProviderNotFound","code":2147749905,"description":"A provider referenced in the schema does not have a corresponding registration."},{"error":"wbemErrInvalidProviderRegistration","code":2147749906,"description":"A provider referenced in the schema has an incorrect or incomplete registration. This error may be caused by a missing pragma namespace command in the MOF file used to register the provider, resulting in the provider being registered in the wrong WMI namespace. This error may also be caused by a corrupt repository, which may be fixed by deleting it and recompiling the MOF files."},{"error":"wbemErrProviderLoadFailure","code":2147749907,"description":"COM cannot locate a provider referenced in the schema. This error may be caused by any of the following:"},{"error":"wbemErrInitializationFailure","code":2147749908,"description":"A component, such as a provider, failed to initialize for internal reasons."},{"error":"wbemErrTransportFailure","code":2147749909,"description":"A networking error occurred, preventing normal operation."},{"error":"wbemErrInvalidOperation","code":2147749910,"description":"The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties."},{"error":"wbemErrInvalidQuery","code":2147749911,"description":"The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties."},{"error":"wbemErrInvalidQueryType","code":2147749912,"description":"The requested query language is not supported."},{"error":"wbemErrAlreadyExists","code":2147749913,"description":"In a put operation, the wbemChangeFlagCreateOnly flag was specified, but the instance already exists."},{"error":"wbemErrOverrideNotAllowed","code":2147749914,"description":"It is not possible to perform the add operation on this qualifier because the owning object does not permit overrides."},{"error":"wbemErrPropagatedQualifier","code":2147749915,"description":"The user attempted to delete a qualifier that was not owned. The qualifier was inherited from a parent class."},{"error":"wbemErrPropagatedProperty","code":2147749916,"description":"The user attempted to delete a property that was not owned. The property was inherited from a parent class."},{"error":"wbemErrUnexpected","code":2147749917,"description":"The client made an unexpected and illegal sequence of calls, such as calling EndEnumeration before calling BeginEnumeration."},{"error":"wbemErrIllegalOperation","code":2147749918,"description":"The user requested an illegal operation, such as spawning a class from an instance."},{"error":"wbemErrCannotBeKey","code":2147749919,"description":"There was an illegal attempt to specify a key qualifier on a property that cannot be a key. The keys are specified in the class definition for an object, and cannot be altered on a per-instance basis."},{"error":"wbemErrIncompleteClass","code":2147749920,"description":"The current object is not a valid class definition. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_."},{"error":"wbemErrInvalidSyntax","code":2147749921,"description":"The syntax of an input parameter is incorrect for the applicable data structure. For example, when a CIM datetime structure does not have the correct format when passed to SWbemDateTime.SetFileTime."},{"error":"wbemErrNondecoratedObject","code":2147749922,"description":"Reserved for future use."},{"error":"wbemErrReadOnly","code":2147749923,"description":"The property that you are attempting to modify is read-only."},{"error":"wbemErrProviderNotCapable","code":2147749924,"description":"The provider cannot perform the requested operation. This would include a query that is too complex, retrieving an instance, creating or updating a class, deleting a class, or enumerating a class."},{"error":"wbemErrClassHasChildren","code":2147749925,"description":"An attempt was made to make a change that would invalidate a subclass."},{"error":"wbemErrClassHasInstances","code":2147749926,"description":"An attempt has been made to delete or modify a class that has instances."},{"error":"wbemErrQueryNotImplemented","code":2147749927,"description":"Reserved for future use."},{"error":"wbemErrIllegalNull","code":2147749928,"description":"A value of Nothing was specified for a property that may not be Nothing, such as one that is marked by a Key, Indexed, or Not_Null qualifier."},{"error":"wbemErrInvalidQualifierType","code":2147749929,"description":"The CIM type specified for a property is not valid."},{"error":"wbemErrInvalidPropertyType","code":2147749930,"description":"The CIM type specified for a property is not valid."},{"error":"wbemErrValueOutOfRange","code":2147749931,"description":"The request was made with an out-of-range value, or is incompatible with the type."},{"error":"wbemErrCannotBeSingleton","code":2147749932,"description":"An illegal attempt was made to make a class singleton, such as when the class is derived from a non-singleton class."},{"error":"wbemErrInvalidCimType","code":2147749933,"description":"The CIM type specified is not valid."},{"error":"wbemErrInvalidMethod","code":2147749934,"description":"The requested method is not available."},{"error":"wbemErrInvalidMethodParameters","code":2147749935,"description":"The parameters provided for the method are not valid."},{"error":"wbemErrSystemProperty","code":2147749936,"description":"There was an attempt to get qualifiers on a system property."},{"error":"wbemErrInvalidProperty","code":2147749937,"description":"The property type is not recognized."},{"error":"wbemErrCallCancelled","code":2147749938,"description":"An asynchronous process has been canceled internally or by the user. Note that due to the timing and nature of the asynchronous operation the operation may not have been truly canceled."},{"error":"wbemErrShuttingDown","code":2147749939,"description":"The user has requested an operation while WMI is in the process of shutting down."},{"error":"wbemErrPropagatedMethod","code":2147749940,"description":"An attempt was made to reuse an existing method name from a parent class, and the signatures did not match."},{"error":"wbemErrUnsupportedParameter","code":2147749941,"description":"One or more parameter values, such as a query text, is too complex or unsupported. WMI is therefore requested to retry the operation with simpler parameters."},{"error":"wbemErrMissingParameter","code":2147749942,"description":"A parameter was missing from the method call."},{"error":"wbemErrInvalidParameterId","code":2147749943,"description":"A method parameter has an ID qualifier that is not valid."},{"error":"wbemErrNonConsecutiveParameterIds","code":2147749944,"description":"One or more of the method parameters have ID qualifiers that are out of sequence."},{"error":"wbemErrParameterIdOnRetval","code":2147749945,"description":"The return value for a method has an ID qualifier."},{"error":"wbemErrInvalidObjectPath","code":2147749946,"description":"The specified object path was not valid."},{"error":"wbemErrOutOfDiskSpace","code":2147749947,"description":"Windows Server 2003: Disk is out of space or the 4 GB limit on WMI repository (CIM repository) size is reached."},{"error":"wbemErrBufferTooSmall","code":2147749948,"description":"The supplied buffer was too small to hold all the objects in the enumerator or to read a string property."},{"error":"wbemErrUnsupportedPutExtension","code":2147749949,"description":"The provider does not support the requested put operation."},{"error":"wbemErrUnknownObjectType","code":2147749950,"description":"An object with an incorrect type or version was encountered during marshaling."},{"error":"wbemErrUnknownPacketType","code":2147749951,"description":"A packet with an incorrect type or version was encountered during marshaling."},{"error":"wbemErrMarshalVersionMismatch","code":2147749952,"description":"The packet has an unsupported version."},{"error":"wbemErrMarshalInvalidSignature","code":2147749953,"description":"The packet appears to be corrupted."},{"error":"wbemErrInvalidQualifier","code":2147749954,"description":"An attempt has been made to mismatch qualifiers, such as putting [key] on an object instead of a property."},{"error":"wbemErrInvalidDuplicateParameter","code":2147749955,"description":"A duplicate parameter has been declared in a CIM method."},{"error":"wbemErrTooMuchData","code":2147749956,"description":"Reserved for future use."},{"error":"wbemErrServerTooBusy","code":2147749957,"description":"A call to IWbemObjectSink::Indicate has failed. The provider may choose to refire the event."},{"error":"wbemErrInvalidFlavor","code":2147749958,"description":"The specified flavor was not valid."},{"error":"wbemErrCircularReference","code":2147749959,"description":"An attempt has been made to create a reference that is circular (for example, deriving a class from itself)."},{"error":"wbemErrUnsupportedClassUpdate","code":2147749960,"description":"The specified class is not supported."},{"error":"wbemErrCannotChangeKeyInheritance","code":2147749961,"description":"An attempt was made to change a key when instances or subclasses are already using the key."},{"error":"wbemErrCannotChangeIndexInheritance","code":2147749968,"description":"An attempt was made to change an index when instances or subclasses are already using the index."},{"error":"wbemErrTooManyProperties","code":2147749969,"description":"An attempt was made to create more properties than the current version of the class supports."},{"error":"wbemErrUpdateTypeMismatch","code":2147749970,"description":"A property was redefined with a conflicting type in a derived class."},{"error":"wbemErrUpdateOverrideNotAllowed","code":2147749971,"description":"An attempt was made in a derived class to override a non-overrideable qualifier."},{"error":"wbemErrUpdatePropagatedMethod","code":2147749972,"description":"A method was redeclared with a conflicting signature in a derived class."},{"error":"wbemErrMethodNotImplemented","code":2147749973,"description":"An attempt was made to execute a method not marked with [implemented] in any relevant class."},{"error":"wbemErrMethodDisabled","code":2147749974,"description":"An attempt was made to execute a method marked with [disabled]."},{"error":"wbemErrRefresherBusy","code":2147749975,"description":"The refresher is busy with another operation."},{"error":"wbemErrUnparsableQuery","code":2147749976,"description":"The filtering query is syntactically not valid."},{"error":"wbemErrNotEventClass","code":2147749977,"description":"The FROM clause of a filtering query references a class that is not an event class (not derived from __Event)."},{"error":"wbemErrMissingGroupWithin","code":2147749978,"description":"A GROUP BY clause was used without the corresponding GROUP WITHIN clause."},{"error":"wbemErrMissingAggregationList","code":2147749979,"description":"A GROUP BY clause was used. Aggregation on all properties is not supported."},{"error":"wbemErrPropertyNotAnObject","code":2147749980,"description":"Dot notation was used on a property that is not an embedded object."},{"error":"wbemErrAggregatingByObject","code":2147749981,"description":"A GROUP BY clause references a property that is an embedded object without using dot notation."},{"error":"wbemErrUninterpretableProviderQuery","code":2147749983,"description":"An event provider registration query ( __EventProviderRegistration) did not specify the classes for which events were provided."},{"error":"wbemErrBackupRestoreWinmgmtRunning","code":2147749984,"description":"An request was made to back up or restore the repository while WMI was using it."},{"error":"wbemErrQueueOverflow","code":2147749985,"description":"The asynchronous delivery queue overflowed due to the event consumer being too slow."},{"error":"wbemErrPrivilegeNotHeld","code":2147749986,"description":"The operation failed because the client did not have the necessary security privilege."},{"error":"wbemErrInvalidOperator","code":2147749987,"description":"The operator is not valid for this property type."},{"error":"wbemErrLocalCredentials","code":2147749988,"description":"The user specified a username, password or authority for a local connection. The user must use a blank username/password and rely on default security."},{"error":"wbemErrCannotBeAbstract","code":2147749989,"description":"The class was made abstract when its parent class is not abstract."},{"error":"wbemErrAmendedObject","code":2147749990,"description":"An amended object was put without the wbemFlagUseAmendedQualifiers flag being specified."},{"error":"wbemErrClientTooSlow","code":2147749991,"description":"Windows Server 2003: The client was not retrieving objects quickly enough from an enumeration. This constant is returned when a client creates an enumeration object but does not retrieve objects from the enumerator in a timely fashion, causing the enumerator\\'s object caches to get backed up."},{"error":"wbemErrNullSecurityDescriptor","code":2147749992,"description":"Windows Server 2003: A null security descriptor was used."},{"error":"wbemErrTimeout","code":2147749993,"description":"Windows Server 2003: The operation timed out."},{"error":"wbemErrInvalidAssociation","code":2147749994,"description":"Windows Server 2003: The association being used is not valid."},{"error":"wbemErrAmbiguousOperation","code":2147749995,"description":"Windows Server 2003: The operation was ambiguous."},{"error":"wbemErrQuotaViolation","code":2147749996,"description":"Windows Server 2003: WMI is taking up too much memory. This could be caused either by low memory availability or excessive memory consumption by WMI."},{"error":"wbemErrTransactionConflict","code":2147749997,"description":"Windows Server 2003: The operation resulted in a transaction conflict."},{"error":"wbemErrForcedRollback","code":2147749998,"description":"Windows Server 2003: The transaction forced a rollback."},{"error":"wbemErrUnsupportedLocale","code":2147749999,"description":"Windows Server 2003: The locale used in the call is not supported."},{"error":"wbemErrHandleOutOfDate","code":2147750000,"description":"Windows Server 2003: The object handle is out of date."},{"error":"wbemErrConnectionFailed","code":2147750001,"description":"Windows Server 2003: Indicates that the connection to the SQL database failed."},{"error":"wbemErrInvalidHandleRequest","code":2147750002,"description":"Windows Server 2003: The handle request was not valid."},{"error":"wbemErrPropertyNameTooWide","code":2147750003,"description":"Windows Server 2003: The property name contains more than 255 characters."},{"error":"wbemErrClassNameTooWide","code":2147750004,"description":"Windows Server 2003: The class name contains more than 255 characters."},{"error":"wbemErrMethodNameTooWide","code":2147750005,"description":"Windows Server 2003: The method name contains more than 255 characters."},{"error":"wbemErrQualifierNameTooWide","code":2147750006,"description":"Windows Server 2003: The qualifier name contains more than 255 characters."},{"error":"wbemErrRerunCommand","code":2147750007,"description":"Windows Server 2003: Indicates that an SQL command should be rerun because there is a deadlock in SQL. This can be returned only when data is being stored in an SQL database."},{"error":"wbemErrDatabaseVerMismatch","code":2147750008,"description":"Windows Server 2003: The database version does not match the version that the repository driver processes."},{"error":"wbemErrVetoDelete","code":2147750010,"description":"Windows Server 2003: WMI cannot do the delete operation because the provider does not allow it."},{"error":"wbemErrVetoPut","code":2147750010,"description":"Windows Server 2003: WMI cannot do the put operation because the provider does not allow it."},{"error":"wbemErrInvalidLocale","code":2147750016,"description":"Windows Server 2003: The specified locale identifier was not valid for the operation."},{"error":"wbemErrProviderSuspended","code":2147750017,"description":"Windows Server 2003: The provider is suspended."},{"error":"wbemErrSynchronizationRequired","code":2147750018,"description":"Windows Server 2003: The object must be committed and retrieved again before the requested operation can succeed. This constant is returned when an object must be committed and re-retrieved to see the property value."},{"error":"wbemErrNoSchema","code":2147750019,"description":"Windows Server 2003: The operation cannot be completed because no schema is available."},{"error":"wbemErrProviderAlreadyRegistered","code":2147750020,"description":"Windows Server 2003: The provider registration cannot be done because the provider is already registered."},{"error":"wbemErrProviderNotRegistered","code":2147750021,"description":"Windows Server 2003: The provider for the requested data is not registered."},{"error":"wbemErrFatalTransportError","code":2147750022,"description":"Windows Server 2003: A fatal transport error occurred and other transport will not be attempted."},{"error":"wbemErrEncryptedConnectionRequired","code":2147750023,"description":"Windows Server 2003: The client connection to WINMGMT must be encrypted for this operation. The IWbemServices proxy security settings should be adjusted and the operation retried."},{"error":"wbemErrRegistrationTooBroad","code":2147753985,"description":"Windows Server 2003: The provider registration overlaps with the system event domain."},{"error":"wbemErrRegistrationTooPrecise","code":2147753986,"description":"Windows Server 2003: A WITHIN clause was not used in this query."},{"error":"wbemErrTimedout","code":2147758081,"description":"Windows Server 2003: Automation-specific error."},{"error":"wbemErrResetToDefault","code":2147758082}] 2 | -------------------------------------------------------------------------------- /winerrors/error.txt: -------------------------------------------------------------------------------- 1 | wbemErrFailed 2 | 2147749889 (0x80041001) 3 | The call failed. 4 | wbemErrNotFound 5 | 2147749890 6 | The object could not be found. 7 | wbemErrAccessDenied 8 | 2147749891 (0x80041003) 9 | The current user does not have permission to perform the action. 10 | wbemErrProviderFailure 11 | 2147749892 (0x80041004) 12 | The provider has failed at some time other than during initialization. 13 | wbemErrTypeMismatch 14 | 2147749893 (0x80041005) 15 | A type mismatch occurred. 16 | wbemErrOutOfMemory 17 | 2147749894 (0x80041006) 18 | There was not enough memory for the operation. 19 | wbemErrInvalidContext 20 | 2147749895 (0x80041007) 21 | The SWbemNamedValue object is not valid. 22 | wbemErrInvalidParameter 23 | 2147749896 (0x80041008) 24 | One of the parameters to the call is not correct. 25 | wbemErrNotAvailable 26 | 2147749897 (0x80041009) 27 | The resource, typically a remote server, is not currently available. 28 | wbemErrCriticalError 29 | 2147749898 (0x8004100A) 30 | An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support. 31 | wbemErrInvalidStream 32 | 2147749899 (0x8004100B) 33 | One or more network packets were corrupted during a remote session. 34 | wbemErrNotSupported 35 | 2147749900 (0x8004100C) 36 | The feature or operation is not supported. 37 | wbemErrInvalidSuperclass 38 | 2147749901 (0x8004100D) 39 | The parent class specified is not valid. 40 | wbemErrInvalidNamespace 41 | 2147749902 (0x8004100E) 42 | The namespace specified could not be found. 43 | wbemErrInvalidObject 44 | 2147749903 (0x8004100F) 45 | The specified instance is not valid. 46 | wbemErrInvalidClass 47 | 2147749904 (0x80041010) 48 | The specified class is not valid. 49 | wbemErrProviderNotFound 50 | 2147749905 (0x80041011) 51 | A provider referenced in the schema does not have a corresponding registration. 52 | wbemErrInvalidProviderRegistration 53 | 2147749906 (0x80041012) 54 | A provider referenced in the schema has an incorrect or incomplete registration. This error may be caused by a missing pragma namespace command in the MOF file used to register the provider, resulting in the provider being registered in the wrong WMI namespace. This error may also be caused by a corrupt repository, which may be fixed by deleting it and recompiling the MOF files. 55 | wbemErrProviderLoadFailure 56 | 2147749907 (0x80041013) 57 | COM cannot locate a provider referenced in the schema. This error may be caused by any of the following: 58 | The provider is using a WMI DLL that does not match the .lib fileused when the provider was built. 59 | The provider's DLL or any of the DLLs on which it depends is corrupt. 60 | The provider failed to export DllRegisterServer. 61 | An in-process provider was not registered using /regsvr32. 62 | An out-of-process provider was not registered using /regserver. 63 | wbemErrInitializationFailure 64 | 2147749908 (0x80041014) 65 | A component, such as a provider, failed to initialize for internal reasons. 66 | wbemErrTransportFailure 67 | 2147749909 (0x80041015) 68 | A networking error occurred, preventing normal operation. 69 | wbemErrInvalidOperation 70 | 2147749910 (0x80041016) 71 | The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties. 72 | wbemErrInvalidQuery 73 | 2147749911 (0x80041017) 74 | The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties. 75 | wbemErrInvalidQueryType 76 | 2147749912 (0x80041018) 77 | The requested query language is not supported. 78 | wbemErrAlreadyExists 79 | 2147749913 (0x80041019) 80 | In a put operation, the wbemChangeFlagCreateOnly flag was specified, but the instance already exists. 81 | wbemErrOverrideNotAllowed 82 | 2147749914 (0x8004101A) 83 | It is not possible to perform the add operation on this qualifier because the owning object does not permit overrides. 84 | wbemErrPropagatedQualifier 85 | 2147749915 (0x8004101B) 86 | The user attempted to delete a qualifier that was not owned. The qualifier was inherited from a parent class. 87 | wbemErrPropagatedProperty 88 | 2147749916 (0x8004101C) 89 | The user attempted to delete a property that was not owned. The property was inherited from a parent class. 90 | wbemErrUnexpected 91 | 2147749917 (0x8004101D) 92 | The client made an unexpected and illegal sequence of calls, such as calling EndEnumeration before calling BeginEnumeration. 93 | wbemErrIllegalOperation 94 | 2147749918 (0x8004101E) 95 | The user requested an illegal operation, such as spawning a class from an instance. 96 | wbemErrCannotBeKey 97 | 2147749919 (0x8004101F) 98 | There was an illegal attempt to specify a key qualifier on a property that cannot be a key. The keys are specified in the class definition for an object, and cannot be altered on a per-instance basis. 99 | wbemErrIncompleteClass 100 | 2147749920 (0x80041020) 101 | The current object is not a valid class definition. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_. 102 | wbemErrInvalidSyntax 103 | 2147749921 (0x80041021) 104 | The syntax of an input parameter is incorrect for the applicable data structure. For example, when a CIM datetime structure does not have the correct format when passed to SWbemDateTime.SetFileTime. 105 | wbemErrNondecoratedObject 106 | 2147749922 (0x80041022) 107 | Reserved for future use. 108 | wbemErrReadOnly 109 | 2147749923 (0x80041023) 110 | The property that you are attempting to modify is read-only. 111 | wbemErrProviderNotCapable 112 | 2147749924 (0x80041024) 113 | The provider cannot perform the requested operation. This would include a query that is too complex, retrieving an instance, creating or updating a class, deleting a class, or enumerating a class. 114 | wbemErrClassHasChildren 115 | 2147749925 (0x80041025) 116 | An attempt was made to make a change that would invalidate a subclass. 117 | wbemErrClassHasInstances 118 | 2147749926 (0x80041026) 119 | An attempt has been made to delete or modify a class that has instances. 120 | wbemErrQueryNotImplemented 121 | 2147749927 (0x80041027) 122 | Reserved for future use. 123 | wbemErrIllegalNull 124 | 2147749928 (0x80041028) 125 | A value of Nothing was specified for a property that may not be Nothing, such as one that is marked by a Key, Indexed, or Not_Null qualifier. 126 | wbemErrInvalidQualifierType 127 | 2147749929 (0x80041029) 128 | The CIM type specified for a property is not valid. 129 | wbemErrInvalidPropertyType 130 | 2147749930 (0x8004102A) 131 | The CIM type specified for a property is not valid. 132 | wbemErrValueOutOfRange 133 | 2147749931 (0x8004102B) 134 | The request was made with an out-of-range value, or is incompatible with the type. 135 | wbemErrCannotBeSingleton 136 | 2147749932 (0x8004102C) 137 | An illegal attempt was made to make a class singleton, such as when the class is derived from a non-singleton class. 138 | wbemErrInvalidCimType 139 | 2147749933 (0x8004102D) 140 | The CIM type specified is not valid. 141 | wbemErrInvalidMethod 142 | 2147749934 (0x8004102E) 143 | The requested method is not available. 144 | wbemErrInvalidMethodParameters 145 | 2147749935 (0x8004102F) 146 | The parameters provided for the method are not valid. 147 | wbemErrSystemProperty 148 | 2147749936 (0x80041030) 149 | There was an attempt to get qualifiers on a system property. 150 | wbemErrInvalidProperty 151 | 2147749937 (0x80041031) 152 | The property type is not recognized. 153 | wbemErrCallCancelled 154 | 2147749938 (0x80041032) 155 | An asynchronous process has been canceled internally or by the user. Note that due to the timing and nature of the asynchronous operation the operation may not have been truly canceled. 156 | wbemErrShuttingDown 157 | 2147749939 (0x80041033) 158 | The user has requested an operation while WMI is in the process of shutting down. 159 | wbemErrPropagatedMethod 160 | 2147749940 (0x80041034) 161 | An attempt was made to reuse an existing method name from a parent class, and the signatures did not match. 162 | wbemErrUnsupportedParameter 163 | 2147749941 (0x80041035) 164 | One or more parameter values, such as a query text, is too complex or unsupported. WMI is therefore requested to retry the operation with simpler parameters. 165 | wbemErrMissingParameter 166 | 2147749942 (0x80041036) 167 | A parameter was missing from the method call. 168 | wbemErrInvalidParameterId 169 | 2147749943 (0x80041037) 170 | A method parameter has an ID qualifier that is not valid. 171 | wbemErrNonConsecutiveParameterIds 172 | 2147749944 (0x80041038) 173 | One or more of the method parameters have ID qualifiers that are out of sequence. 174 | wbemErrParameterIdOnRetval 175 | 2147749945 (0x80041039) 176 | The return value for a method has an ID qualifier. 177 | wbemErrInvalidObjectPath 178 | 2147749946 (0x8004103A) 179 | The specified object path was not valid. 180 | wbemErrOutOfDiskSpace 181 | 2147749947 182 | Windows Server 2003: Disk is out of space or the 4 GB limit on WMI repository (CIM repository) size is reached. 183 | wbemErrBufferTooSmall 184 | 2147749948 (0x8004103C) 185 | The supplied buffer was too small to hold all the objects in the enumerator or to read a string property. 186 | wbemErrUnsupportedPutExtension 187 | 2147749949 (0x8004103D) 188 | The provider does not support the requested put operation. 189 | wbemErrUnknownObjectType 190 | 2147749950 (0x8004103E) 191 | An object with an incorrect type or version was encountered during marshaling. 192 | wbemErrUnknownPacketType 193 | 2147749951 (0x8004103F) 194 | A packet with an incorrect type or version was encountered during marshaling. 195 | wbemErrMarshalVersionMismatch 196 | 2147749952 (0x80041040) 197 | The packet has an unsupported version. 198 | wbemErrMarshalInvalidSignature 199 | 2147749953 (0x80041041) 200 | The packet appears to be corrupted. 201 | wbemErrInvalidQualifier 202 | 2147749954 (0x80041042) 203 | An attempt has been made to mismatch qualifiers, such as putting [key] on an object instead of a property. 204 | wbemErrInvalidDuplicateParameter 205 | 2147749955 (0x80041043) 206 | A duplicate parameter has been declared in a CIM method. 207 | wbemErrTooMuchData 208 | 2147749956 (0x80041044) 209 | Reserved for future use. 210 | wbemErrServerTooBusy 211 | 2147749957 (0x80041045) 212 | A call to IWbemObjectSink::Indicate has failed. The provider may choose to refire the event. 213 | wbemErrInvalidFlavor 214 | 2147749958 (0x80041046) 215 | The specified flavor was not valid. 216 | wbemErrCircularReference 217 | 2147749959 (0x80041047) 218 | An attempt has been made to create a reference that is circular (for example, deriving a class from itself). 219 | wbemErrUnsupportedClassUpdate 220 | 2147749960 221 | The specified class is not supported. 222 | wbemErrCannotChangeKeyInheritance 223 | 2147749961 (0x80041049) 224 | An attempt was made to change a key when instances or subclasses are already using the key. 225 | wbemErrCannotChangeIndexInheritance 226 | 2147749968 (0x80041050) 227 | An attempt was made to change an index when instances or subclasses are already using the index. 228 | wbemErrTooManyProperties 229 | 2147749969 (0x80041051) 230 | An attempt was made to create more properties than the current version of the class supports. 231 | wbemErrUpdateTypeMismatch 232 | 2147749970 (0x80041052) 233 | A property was redefined with a conflicting type in a derived class. 234 | wbemErrUpdateOverrideNotAllowed 235 | 2147749971 (0x80041053) 236 | An attempt was made in a derived class to override a non-overrideable qualifier. 237 | wbemErrUpdatePropagatedMethod 238 | 2147749972 (0x80041054) 239 | A method was redeclared with a conflicting signature in a derived class. 240 | wbemErrMethodNotImplemented 241 | 2147749973 (0x80041055) 242 | An attempt was made to execute a method not marked with [implemented] in any relevant class. 243 | wbemErrMethodDisabled 244 | 2147749974 (0x80041056) 245 | An attempt was made to execute a method marked with [disabled]. 246 | wbemErrRefresherBusy 247 | 2147749975 (0x80041057) 248 | The refresher is busy with another operation. 249 | wbemErrUnparsableQuery 250 | 2147749976 (0x80041058) 251 | The filtering query is syntactically not valid. 252 | wbemErrNotEventClass 253 | 2147749977 (0x80041059) 254 | The FROM clause of a filtering query references a class that is not an event class (not derived from __Event). 255 | wbemErrMissingGroupWithin 256 | 2147749978 (0x8004105A) 257 | A GROUP BY clause was used without the corresponding GROUP WITHIN clause. 258 | wbemErrMissingAggregationList 259 | 2147749979 (0x8004105B) 260 | A GROUP BY clause was used. Aggregation on all properties is not supported. 261 | wbemErrPropertyNotAnObject 262 | 2147749980 (0x8004105C) 263 | Dot notation was used on a property that is not an embedded object. 264 | wbemErrAggregatingByObject 265 | 2147749981 (0x8004105D) 266 | A GROUP BY clause references a property that is an embedded object without using dot notation. 267 | wbemErrUninterpretableProviderQuery 268 | 2147749983 (0x8004105F) 269 | An event provider registration query ( __EventProviderRegistration) did not specify the classes for which events were provided. 270 | wbemErrBackupRestoreWinmgmtRunning 271 | 2147749984 (0x80041060) 272 | An request was made to back up or restore the repository while WMI was using it. 273 | wbemErrQueueOverflow 274 | 2147749985 (0x80041061) 275 | The asynchronous delivery queue overflowed due to the event consumer being too slow. 276 | wbemErrPrivilegeNotHeld 277 | 2147749986 (0x80041062) 278 | The operation failed because the client did not have the necessary security privilege. 279 | wbemErrInvalidOperator 280 | 2147749987 (0x80041063) 281 | The operator is not valid for this property type. 282 | wbemErrLocalCredentials 283 | 2147749988 (0x80041064) 284 | The user specified a username, password or authority for a local connection. The user must use a blank username/password and rely on default security. 285 | wbemErrCannotBeAbstract 286 | 2147749989 (0x80041065) 287 | The class was made abstract when its parent class is not abstract. 288 | wbemErrAmendedObject 289 | 2147749990 (0x80041066) 290 | An amended object was put without the wbemFlagUseAmendedQualifiers flag being specified. 291 | wbemErrClientTooSlow 292 | 2147749991 (0x80041067) 293 | Windows Server 2003: The client was not retrieving objects quickly enough from an enumeration. This constant is returned when a client creates an enumeration object but does not retrieve objects from the enumerator in a timely fashion, causing the enumerator's object caches to get backed up. 294 | wbemErrNullSecurityDescriptor 295 | 2147749992 (0x80041068) 296 | Windows Server 2003: A null security descriptor was used. 297 | wbemErrTimeout 298 | 2147749993 (0x80041069) 299 | Windows Server 2003: The operation timed out. 300 | wbemErrInvalidAssociation 301 | 2147749994 (0x8004106A) 302 | Windows Server 2003: The association being used is not valid. 303 | wbemErrAmbiguousOperation 304 | 2147749995 (0x8004106B) 305 | Windows Server 2003: The operation was ambiguous. 306 | wbemErrQuotaViolation 307 | 2147749996 (0x8004106C) 308 | Windows Server 2003: WMI is taking up too much memory. This could be caused either by low memory availability or excessive memory consumption by WMI. 309 | wbemErrTransactionConflict 310 | 2147749997 (0x8004106D) 311 | Windows Server 2003: The operation resulted in a transaction conflict. 312 | wbemErrForcedRollback 313 | 2147749998 (0x8004106E) 314 | Windows Server 2003: The transaction forced a rollback. 315 | wbemErrUnsupportedLocale 316 | 2147749999 (0x8004106F) 317 | Windows Server 2003: The locale used in the call is not supported. 318 | wbemErrHandleOutOfDate 319 | 2147750000 (0x80041070) 320 | Windows Server 2003: The object handle is out of date. 321 | wbemErrConnectionFailed 322 | 2147750001 (0x80041071) 323 | Windows Server 2003: Indicates that the connection to the SQL database failed. 324 | wbemErrInvalidHandleRequest 325 | 2147750002 (0x80041072) 326 | Windows Server 2003: The handle request was not valid. 327 | wbemErrPropertyNameTooWide 328 | 2147750003 (0x80041073) 329 | Windows Server 2003: The property name contains more than 255 characters. 330 | wbemErrClassNameTooWide 331 | 2147750004 (0x80041074) 332 | Windows Server 2003: The class name contains more than 255 characters. 333 | wbemErrMethodNameTooWide 334 | 2147750005 (0x80041075) 335 | Windows Server 2003: The method name contains more than 255 characters. 336 | wbemErrQualifierNameTooWide 337 | 2147750006 (0x80041076) 338 | Windows Server 2003: The qualifier name contains more than 255 characters. 339 | wbemErrRerunCommand 340 | 2147750007 (0x80041077) 341 | Windows Server 2003: Indicates that an SQL command should be rerun because there is a deadlock in SQL. This can be returned only when data is being stored in an SQL database. 342 | wbemErrDatabaseVerMismatch 343 | 2147750008 (0x80041078) 344 | Windows Server 2003: The database version does not match the version that the repository driver processes. 345 | wbemErrVetoDelete 346 | 2147750010 (0x8004107A) 347 | Windows Server 2003: WMI cannot do the delete operation because the provider does not allow it. 348 | wbemErrVetoPut 349 | 2147750010 (0x8004107A) 350 | Windows Server 2003: WMI cannot do the put operation because the provider does not allow it. 351 | wbemErrInvalidLocale 352 | 2147750016 (0x80041080) 353 | Windows Server 2003: The specified locale identifier was not valid for the operation. 354 | wbemErrProviderSuspended 355 | 2147750017 (0x80041081) 356 | Windows Server 2003: The provider is suspended. 357 | wbemErrSynchronizationRequired 358 | 2147750018 (0x80041082) 359 | Windows Server 2003: The object must be committed and retrieved again before the requested operation can succeed. This constant is returned when an object must be committed and re-retrieved to see the property value. 360 | wbemErrNoSchema 361 | 2147750019 (0x80041083) 362 | Windows Server 2003: The operation cannot be completed because no schema is available. 363 | wbemErrProviderAlreadyRegistered 364 | 2147750020 (0x80041084) 365 | Windows Server 2003: The provider registration cannot be done because the provider is already registered. 366 | wbemErrProviderNotRegistered 367 | 2147750021 (0x80041085) 368 | Windows Server 2003: The provider for the requested data is not registered. 369 | wbemErrFatalTransportError 370 | 2147750022 (0x80041086) 371 | Windows Server 2003: A fatal transport error occurred and other transport will not be attempted. 372 | wbemErrEncryptedConnectionRequired 373 | 2147750023 (0x80041087) 374 | Windows Server 2003: The client connection to WINMGMT must be encrypted for this operation. The IWbemServices proxy security settings should be adjusted and the operation retried. 375 | See WBEM_E_PROVIDER_TIMED_OUT in WMI Error Constants 376 | 2147750024 (0x80041088) 377 | Windows Server 2003: A provider failed to report results within the specified timeout. 378 | See WBEM_E_NO_KEY in WMI Error Constants 379 | 2147750025 (0x80041089) 380 | Windows Server 2003: User attempted to put an instance with no defined key. 381 | See WBEM_E_PROVIDER_DISABLED in WMI Error Constants 382 | 2147750026 (0x8004108A) 383 | Windows Server 2003: User attempted to register a provider instance but the COM server for the provider instance was unloaded. 384 | wbemErrRegistrationTooBroad 385 | 2147753985 (0x80042001) 386 | Windows Server 2003: The provider registration overlaps with the system event domain. 387 | wbemErrRegistrationTooPrecise 388 | 2147753986 (0x80042002) 389 | Windows Server 2003: A WITHIN clause was not used in this query. 390 | wbemErrTimedout 391 | 2147758081 (0x80043001) 392 | Windows Server 2003: Automation-specific error. 393 | wbemErrResetToDefault 394 | 2147758082 (0x80043002) -------------------------------------------------------------------------------- /test/regedit.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-expressions */ 2 | 3 | // TODO need to find a better way to test the 32bit/64bit specific scenarios 4 | 5 | var index = require('../index') 6 | var should = require('should') 7 | 8 | function toLowerCase(str) { 9 | return str.toLowerCase() 10 | } 11 | 12 | describe('regedit', function() { 13 | describe('list keys and values in a sub key', function() { 14 | this.timeout(5000) 15 | 16 | var target = 'HKLM\\software\\microsoft\\windows\\CurrentVersion' 17 | 18 | it(target, function(done) { 19 | index.list(target, function(err, result) { 20 | if (err) { 21 | return done(err) 22 | } 23 | 24 | result.should.have.property(target) 25 | 26 | var key = result[target] 27 | 28 | key.should.have.property('exists') 29 | key.exists.should.eql(true) 30 | 31 | key.should.have.property('keys') 32 | key.keys.map(toLowerCase).should.containEql('policies') 33 | 34 | key.should.have.property('values') 35 | key.values.should.have.property('ProgramFilesDir') 36 | key.values.ProgramFilesDir.should.have.property('value') 37 | key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0) 38 | key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ') 39 | 40 | done() 41 | }) 42 | }) 43 | 44 | it(target + ' 32bit', function(done) { 45 | this.timeout(5000) 46 | index.arch.list32(target, function(err, result) { 47 | if (err) { 48 | return done(err) 49 | } 50 | 51 | result.should.have.property(target) 52 | 53 | var key = result[target] 54 | 55 | key.should.have.property('exists') 56 | key.exists.should.eql(true) 57 | 58 | key.should.have.property('keys') 59 | key.keys.map(toLowerCase).should.containEql('policies') 60 | 61 | key.should.have.property('values') 62 | key.values.should.have.property('ProgramFilesDir') 63 | key.values.ProgramFilesDir.should.have.property('value') 64 | key.values.ProgramFilesDir.value.indexOf('C:\\Program Files').should.eql(0) 65 | key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ') 66 | 67 | done() 68 | }) 69 | }) 70 | 71 | it(target + ' 64bit', function(done) { 72 | index.arch.list64(target, function(err, result) { 73 | if (err) { 74 | return done(err) 75 | } 76 | 77 | result.should.have.property(target) 78 | 79 | var key = result[target] 80 | 81 | key.should.have.property('exists') 82 | key.exists.should.eql(true) 83 | 84 | key.should.have.property('keys') 85 | key.keys.map(toLowerCase).should.containEql('policies') 86 | 87 | key.should.have.property('values') 88 | key.values.should.have.property('ProgramFilesDir') 89 | key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files') 90 | key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ') 91 | 92 | done() 93 | }) 94 | }) 95 | 96 | it(target + ' arch auto pick', function(done) { 97 | index.arch.list(target, function(err, result) { 98 | if (err) { 99 | return done(err) 100 | } 101 | 102 | result.should.have.property(target) 103 | 104 | var key = result[target] 105 | 106 | key.should.have.property('exists') 107 | key.exists.should.eql(true) 108 | 109 | key.should.have.property('keys') 110 | key.keys.map(toLowerCase).should.containEql('policies') 111 | 112 | key.should.have.property('values') 113 | key.values.should.have.property('ProgramFilesDir') 114 | key.values.ProgramFilesDir.should.have.property('value', 'C:\\Program Files') 115 | key.values.ProgramFilesDir.should.have.property('type', 'REG_SZ') 116 | 117 | done() 118 | }) 119 | }) 120 | 121 | it('can be applied to several independant keys at once', function(done) { 122 | index.list(['hklm', 'hkcu'], function(err, result) { 123 | if (err) { 124 | return done(err) 125 | } 126 | 127 | result.should.have.property('hklm') 128 | 129 | result.hklm.should.have.property('exists') 130 | result.hklm.exists.should.eql(true) 131 | 132 | result.hklm.should.have.property('keys') 133 | result.hklm.keys.map(toLowerCase).should.containEql('software') 134 | 135 | result.should.have.property('hkcu') 136 | 137 | result.hkcu.should.have.property('exists') 138 | result.hkcu.exists.should.eql(true) 139 | 140 | result.hkcu.should.have.property('keys') 141 | result.hkcu.keys.map(toLowerCase).should.containEql('software') 142 | 143 | done() 144 | }) 145 | }) 146 | 147 | it('handle spaces in registry keys', function(done) { 148 | var key = 'HKCU\\Keyboard Layout' 149 | 150 | index.list([key], function(err, result) { 151 | if (err) { 152 | return done(err) 153 | } 154 | 155 | result[key].should.have.property('exists') 156 | result[key].exists.should.eql(true) 157 | 158 | result[key].should.have.property('keys') 159 | result[key].keys.map(toLowerCase).should.containEql('preload') 160 | result[key].keys.map(toLowerCase).should.containEql('substitutes') 161 | result[key].keys.map(toLowerCase).should.containEql('toggle') 162 | 163 | done() 164 | }) 165 | }) 166 | 167 | it.skip('reads unicode characters from the registry - need to manually create', function(done) { 168 | var key = 'HKCU\\software\\ironsource\\' 169 | 170 | index.list(key, function(err, result) { 171 | if (err) { 172 | return done(err) 173 | } 174 | 175 | result[key].should.have.property('exists') 176 | result[key].exists.should.eql(true) 177 | 178 | result[key].should.have.property('keys') 179 | result[key].keys.should.containEql('测试') 180 | 181 | done() 182 | }) 183 | }) 184 | 185 | it('will fail for unknown hives', function(done) { 186 | index.list('lala\\software', function(err) { 187 | should(err).not.be.null 188 | err.message.should.eql('unsupported hive') 189 | done() 190 | }) 191 | }) 192 | 193 | it('lists default values', function(done) { 194 | index.list('HKCR\\Directory\\shell\\cmd\\command', function(err, results) { 195 | if (err) { 196 | return done(err) 197 | } 198 | results['HKCR\\Directory\\shell\\cmd\\command'].should.have.property('exists') 199 | results['HKCR\\Directory\\shell\\cmd\\command'].exists.should.eql(true) 200 | results['HKCR\\Directory\\shell\\cmd\\command'].should.have.property('values') 201 | results['HKCR\\Directory\\shell\\cmd\\command'].values.should.have.property('') 202 | done() 203 | }) 204 | }) 205 | }) 206 | 207 | describe('create keys', function() { 208 | var key = 'HKCU\\software\\ironSource\\regedit\\test\\' 209 | var now = Date.now().toString() 210 | 211 | it('will throw an error if we dont have permission', function(done) { 212 | index.createKey('HKLM\\SECURITY\\unauthorized', function(err) { 213 | err.should.be.an.Error 214 | err.message.should.eql('access is denied') 215 | done() 216 | }) 217 | }) 218 | 219 | it(key + now, function(done) { 220 | index.createKey(key + now, function(err) { 221 | if (err) { 222 | return done(err) 223 | } 224 | 225 | // testing using the module itself is not the best idea... 226 | index.list(key, function(err, result) { 227 | if (err) { 228 | return done(err) 229 | } 230 | 231 | result[key].keys.should.containEql(now) 232 | done() 233 | }) 234 | }) 235 | }) 236 | 237 | it(key + now + '测试', function(done) { 238 | index.createKey(key + now + '测试', function(err) { 239 | if (err) { 240 | return done(err) 241 | } 242 | 243 | index.list(key, function(err, results) { 244 | if (err) { 245 | return done(err) 246 | } 247 | 248 | results[key].should.have.property('keys') 249 | results[key].keys.should.containEql(now + '测试') 250 | 251 | done() 252 | }) 253 | }) 254 | }) 255 | 256 | it(key + now + ' S', function(done) { 257 | index.arch.createKey(key + now, function(err) { 258 | if (err) { 259 | return done(err) 260 | } 261 | 262 | // testing using the module itself is not the best idea... 263 | index.arch.list(key, function(err, result) { 264 | if (err) { 265 | return done(err) 266 | } 267 | 268 | result[key].keys.should.containEql(now) 269 | done() 270 | }) 271 | }) 272 | }) 273 | 274 | it(key + now + ' 32bit', function(done) { 275 | index.arch.createKey32(key + now, function(err) { 276 | if (err) { 277 | return done(err) 278 | } 279 | 280 | // testing using the module itself is not the best idea... 281 | index.arch.list32(key, function(err, result) { 282 | if (err) { 283 | return done(err) 284 | } 285 | 286 | result[key].keys.should.containEql(now) 287 | done() 288 | }) 289 | }) 290 | }) 291 | 292 | it(key + now + ' 64bit', function(done) { 293 | index.arch.createKey64(key + now, function(err) { 294 | if (err) { 295 | return done(err) 296 | } 297 | 298 | // testing using the module itself is not the best idea... 299 | index.arch.list64(key, function(err, result) { 300 | if (err) { 301 | return done(err) 302 | } 303 | 304 | result[key].keys.should.containEql(now) 305 | done() 306 | }) 307 | }) 308 | }) 309 | 310 | afterEach(function() { 311 | now = Date.now().toString() 312 | }) 313 | }) 314 | 315 | describe('delete keys', function() { 316 | var key = 'HKCU\\software\\ironSource\\regedit\\test\\' 317 | var now = Date.now().toString() 318 | 319 | it('will throw an error if we attempt to delete a key without permission', function(done) { 320 | index.deleteKey('HKLM\\SECURITY', function(err) { 321 | err.should.be.an.Error 322 | err.message.should.eql('access is denied') 323 | done() 324 | }) 325 | }) 326 | 327 | it(key + now, function(done) { 328 | index.createKey(key + now, function(err) { 329 | if (err) { 330 | return done(err) 331 | } 332 | 333 | index.list(key, function(err, result) { 334 | if (err) { 335 | return done(err) 336 | } 337 | 338 | result[key].keys.should.containEql(now) 339 | 340 | index.deleteKey(key + now, function(err) { 341 | if (err) { 342 | return done(err) 343 | } 344 | 345 | index.list(key, function(err, result1) { 346 | if (err) { 347 | return done(err) 348 | } 349 | 350 | result1[key].keys.should.not.containEql(now) 351 | done() 352 | }) 353 | }) 354 | }) 355 | }) 356 | }) 357 | 358 | it(key + now + ' S', function(done) { 359 | index.arch.createKey(key + now, function(err) { 360 | if (err) { 361 | return done(err) 362 | } 363 | 364 | index.arch.list(key, function(err, result) { 365 | if (err) { 366 | return done(err) 367 | } 368 | 369 | result[key].keys.should.containEql(now) 370 | 371 | index.arch.deleteKey(key + now, function(err) { 372 | if (err) { 373 | return done(err) 374 | } 375 | 376 | index.list(key, function(err, result1) { 377 | if (err) { 378 | return done(err) 379 | } 380 | 381 | result1[key].keys.should.not.containEql(now) 382 | done() 383 | }) 384 | }) 385 | }) 386 | }) 387 | }) 388 | 389 | it(key + now + ' 32bit', function(done) { 390 | index.arch.createKey32(key + now, function(err) { 391 | if (err) { 392 | return done(err) 393 | } 394 | 395 | index.arch.list32(key, function(err, result) { 396 | if (err) { 397 | return done(err) 398 | } 399 | 400 | result[key].keys.should.containEql(now) 401 | 402 | index.arch.deleteKey32(key + now, function(err) { 403 | if (err) { 404 | return done(err) 405 | } 406 | 407 | index.list(key, function(err, result1) { 408 | if (err) { 409 | return done(err) 410 | } 411 | 412 | result1[key].keys.should.not.containEql(now) 413 | done() 414 | }) 415 | }) 416 | }) 417 | }) 418 | }) 419 | 420 | it(key + now + ' 64bit', function(done) { 421 | index.arch.createKey64(key + now, function(err) { 422 | if (err) { 423 | return done(err) 424 | } 425 | 426 | index.arch.list64(key, function(err, result) { 427 | if (err) { 428 | return done(err) 429 | } 430 | 431 | result[key].keys.should.containEql(now) 432 | 433 | index.arch.deleteKey64(key + now, function(err) { 434 | if (err) { 435 | return done(err) 436 | } 437 | 438 | index.list(key, function(err, result1) { 439 | if (err) { 440 | return done(err) 441 | } 442 | 443 | result1[key].keys.should.not.containEql(now) 444 | done() 445 | }) 446 | }) 447 | }) 448 | }) 449 | }) 450 | 451 | afterEach(function() { 452 | now = Date.now().toString() 453 | }) 454 | }) 455 | 456 | describe('put values', function() { 457 | var key = 'HKCU\\software\\ironSource\\regedit\\test\\' 458 | var now = Date.now().toString() 459 | var map = {} 460 | 461 | it('in ' + key + now, function(done) { 462 | index.putValue(map, function(err) { 463 | if (err) { 464 | return done(err) 465 | } 466 | 467 | index.list(key + now, function(err, result) { 468 | if (err) { 469 | console.error(result) 470 | return done(err) 471 | } 472 | 473 | var values = result[key + now].values 474 | 475 | values.should.have.property('a key') 476 | values['a key'].type.should.eql('REG_SZ') 477 | values['a key'].value.should.eql('some string') 478 | 479 | values.should.have.property('b') 480 | values.b.type.should.eql('REG_BINARY') 481 | values.b.value.should.eql([1, 2, 3]) 482 | 483 | values.should.have.property('c') 484 | values.c.type.should.eql('REG_DWORD') 485 | values.c.value.should.eql(10) 486 | 487 | values.should.have.property('d') 488 | values.d.type.should.eql('REG_QWORD') 489 | values.d.value.should.eql(100) 490 | 491 | values.should.have.property('e') 492 | values.e.type.should.eql('REG_EXPAND_SZ') 493 | values.e.value.should.eql('expand_string') 494 | 495 | values.should.have.property('f') 496 | values.f.type.should.eql('REG_MULTI_SZ') 497 | values.f.value.should.eql(['a', 'b', 'c']) 498 | 499 | values.should.have.property('测试') 500 | values['测试'].type.should.eql('REG_SZ') 501 | values['测试'].value.should.eql('值 test for non-English environment') 502 | 503 | values.should.have.property('newline') 504 | values.newline.type.should.eql('REG_SZ') 505 | values.newline.value.should.eql('new\\nline') 506 | 507 | done() 508 | }) 509 | }) 510 | }) 511 | 512 | it('default value in ' + key + now, function(done) { 513 | var values = {} 514 | values[key + now] = { 515 | 'default': { 516 | type: 'reg_default', 517 | value: 'default', 518 | }, 519 | } 520 | 521 | index.putValue(values, function(err) { 522 | if (err) { 523 | return done(err) 524 | } 525 | 526 | index.list(key + now, function(err, results) { 527 | if (err) { 528 | return done(err) 529 | } 530 | results[key + now].should.have.property('values') 531 | results[key + now].values.should.have.property('', { 532 | type: 'REG_SZ', 533 | value: 'default', 534 | }) 535 | done() 536 | }) 537 | }) 538 | }) 539 | 540 | it('in ' + key + now + ' S', function(done) { 541 | index.arch.putValue(map, function(err) { 542 | if (err) { 543 | return done(err) 544 | } 545 | 546 | index.arch.list(key + now, function(err, result) { 547 | if (err) { 548 | return done(err) 549 | } 550 | var values = result[key + now].values 551 | 552 | values.should.have.property('a key') 553 | values['a key'].type.should.eql('REG_SZ') 554 | values['a key'].value.should.eql('some string') 555 | 556 | values.should.have.property('b') 557 | values.b.type.should.eql('REG_BINARY') 558 | values.b.value.should.eql([1, 2, 3]) 559 | 560 | values.should.have.property('c') 561 | values.c.type.should.eql('REG_DWORD') 562 | values.c.value.should.eql(10) 563 | 564 | values.should.have.property('d') 565 | values.d.type.should.eql('REG_QWORD') 566 | values.d.value.should.eql(100) 567 | 568 | values.should.have.property('e') 569 | values.e.type.should.eql('REG_EXPAND_SZ') 570 | values.e.value.should.eql('expand_string') 571 | 572 | values.should.have.property('f') 573 | values.f.type.should.eql('REG_MULTI_SZ') 574 | values.f.value.should.eql(['a', 'b', 'c']) 575 | 576 | values.should.have.property('测试') 577 | values['测试'].type.should.eql('REG_SZ') 578 | values['测试'].value.should.eql('值 test for non-English environment') 579 | 580 | values.should.have.property('newline') 581 | values.newline.type.should.eql('REG_SZ') 582 | values.newline.value.should.eql('new\\nline') 583 | 584 | done() 585 | }) 586 | }) 587 | }) 588 | 589 | it('in ' + key + now + ' 32bit', function(done) { 590 | index.arch.putValue32(map, function(err) { 591 | if (err) { 592 | return done(err) 593 | } 594 | 595 | index.arch.list32(key + now, function(err, result) { 596 | if (err) { 597 | return done(err) 598 | } 599 | var values = result[key + now].values 600 | 601 | values.should.have.property('a key') 602 | values['a key'].type.should.eql('REG_SZ') 603 | values['a key'].value.should.eql('some string') 604 | 605 | values.should.have.property('b') 606 | values.b.type.should.eql('REG_BINARY') 607 | values.b.value.should.eql([1, 2, 3]) 608 | 609 | values.should.have.property('c') 610 | values.c.type.should.eql('REG_DWORD') 611 | values.c.value.should.eql(10) 612 | 613 | values.should.have.property('d') 614 | values.d.type.should.eql('REG_QWORD') 615 | values.d.value.should.eql(100) 616 | 617 | values.should.have.property('e') 618 | values.e.type.should.eql('REG_EXPAND_SZ') 619 | values.e.value.should.eql('expand_string') 620 | 621 | values.should.have.property('f') 622 | values.f.type.should.eql('REG_MULTI_SZ') 623 | values.f.value.should.eql(['a', 'b', 'c']) 624 | 625 | values.should.have.property('测试') 626 | values['测试'].type.should.eql('REG_SZ') 627 | values['测试'].value.should.eql('值 test for non-English environment') 628 | 629 | values.should.have.property('newline') 630 | values.newline.type.should.eql('REG_SZ') 631 | values.newline.value.should.eql('new\\nline') 632 | 633 | done() 634 | }) 635 | }) 636 | }) 637 | 638 | it('in ' + key + now + '64bit', function(done) { 639 | index.arch.putValue64(map, function(err) { 640 | if (err) { 641 | return done(err) 642 | } 643 | 644 | index.arch.list64(key + now, function(err, result) { 645 | if (err) { 646 | return done(err) 647 | } 648 | var values = result[key + now].values 649 | 650 | values.should.have.property('a key') 651 | values['a key'].type.should.eql('REG_SZ') 652 | values['a key'].value.should.eql('some string') 653 | 654 | values.should.have.property('b') 655 | values.b.type.should.eql('REG_BINARY') 656 | values.b.value.should.eql([1, 2, 3]) 657 | 658 | values.should.have.property('c') 659 | values.c.type.should.eql('REG_DWORD') 660 | values.c.value.should.eql(10) 661 | 662 | values.should.have.property('d') 663 | values.d.type.should.eql('REG_QWORD') 664 | values.d.value.should.eql(100) 665 | 666 | values.should.have.property('e') 667 | values.e.type.should.eql('REG_EXPAND_SZ') 668 | values.e.value.should.eql('expand_string') 669 | 670 | values.should.have.property('f') 671 | values.f.type.should.eql('REG_MULTI_SZ') 672 | values.f.value.should.eql(['a', 'b', 'c']) 673 | 674 | values.should.have.property('测试') 675 | values['测试'].type.should.eql('REG_SZ') 676 | values['测试'].value.should.eql('值 test for non-English environment') 677 | 678 | values.should.have.property('newline') 679 | values.newline.type.should.eql('REG_SZ') 680 | values.newline.value.should.eql('new\\nline') 681 | 682 | done() 683 | }) 684 | }) 685 | }) 686 | 687 | beforeEach(function(done) { 688 | index.createKey(key + now, done) 689 | map[key + now] = { 690 | 'a key': { 691 | type: 'reg_sz', 692 | value: 'some string', 693 | }, 694 | 695 | 'b': { 696 | type: 'reg_binary', 697 | value: [1, 2, 3], 698 | }, 699 | 700 | 'c': { 701 | type: 'reg_dword', 702 | value: 10, 703 | }, 704 | 705 | 'd': { 706 | type: 'reg_qword', 707 | value: 100, 708 | }, 709 | 710 | 'e': { 711 | type: 'reg_expand_sz', 712 | value: 'expand_string', 713 | }, 714 | 715 | 'f': { 716 | type: 'reg_multi_sz', 717 | value: ['a', 'b', 'c'], 718 | }, 719 | 720 | '测试': { 721 | type: 'reg_sz', 722 | value: '值 test for non-English environment', 723 | }, 724 | 725 | 'newline': { 726 | type: 'reg_sz', 727 | value: 'new\nline', 728 | }, 729 | } 730 | }) 731 | 732 | afterEach(function() { 733 | now = Date.now().toString() 734 | }) 735 | }) 736 | 737 | describe('delete values', function() { 738 | var key = 'HKCU\\SOFTWARE\\ironSource\\regedit\\test\\' 739 | var now = '' 740 | var map = {} 741 | 742 | function genericTest(arch, done) { 743 | index.arch['putValue' + arch](map, function(err) { 744 | if (err) { 745 | return done(err) 746 | } 747 | 748 | index.arch['list' + arch](key + now, function(err, result) { 749 | if (err) { 750 | return done(err) 751 | } 752 | 753 | var values = result[key + now].values 754 | values.should.have.property('DeleteMe') 755 | 756 | index.arch['deleteValue' + arch](key + now + '\\DeleteMe', function(err) { 757 | if (err) { 758 | return done(err) 759 | } 760 | 761 | index.arch['list' + arch](key + now, function(err, result) { 762 | if (err) { 763 | return done(err) 764 | } 765 | 766 | result[key + now].should.not.have.property('DeleteMe') 767 | 768 | done() 769 | }) 770 | }) 771 | }) 772 | }) 773 | } 774 | 775 | beforeEach(function(done) { 776 | now = Date.now().toString() 777 | map[key + now] = { 778 | 'DeleteMe': { 779 | type: 'reg_sz', 780 | value: 'some string', 781 | }, 782 | } 783 | this.currentTest.title = 'Key: ' + key + now + ' ' + this.currentTest.title 784 | index.createKey(key + now, done) 785 | }) 786 | 787 | it('Agnostic', function(done) { 788 | index.putValue(map, function(err) { 789 | if (err) { 790 | return done(err) 791 | } 792 | 793 | index.list(key + now, function(err, result) { 794 | if (err) { 795 | return done(err) 796 | } 797 | 798 | var values = result[key + now].values 799 | values.should.have.property('DeleteMe') 800 | 801 | index.deleteValue(key + now + '\\DeleteMe', function(err) { 802 | if (err) { 803 | return done(err) 804 | } 805 | 806 | index.list(key + now, function(err, result) { 807 | if (err) { 808 | return done(err) 809 | } 810 | 811 | result[key + now].values.should.not.have.property('DeleteMe') 812 | 813 | done() 814 | }) 815 | }) 816 | }) 817 | }) 818 | }) 819 | 820 | it('Specific', function(done) { 821 | genericTest('', done) 822 | }) 823 | 824 | it('32bit', function(done) { 825 | genericTest('32', done) 826 | }) 827 | 828 | it('64bit', function(done) { 829 | genericTest('64', done) 830 | }) 831 | }) 832 | 833 | describe('listUnexpandedValues', function () { 834 | it('reads values without expanding environment variables embedded in them', function(done) { 835 | const key = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData' 836 | index.listUnexpandedValues(key, function(err, result) { 837 | if (err) { 838 | return done(err) 839 | } 840 | 841 | result.should.deepEqual([{ 842 | path: 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 843 | exists: true, 844 | value: '%USERPROFILE%\\AppData\\Roaming', 845 | }]) 846 | 847 | done() 848 | }) 849 | }) 850 | 851 | it('does not fail for values that dont exist', function(done) { 852 | index.listUnexpandedValues('HKCU\\Software\\Microsoft\\blabla', function(err, result) { 853 | if (err) { 854 | return done(err) 855 | } 856 | 857 | result.should.deepEqual([{ 858 | path: 'HKCU\\Software\\Microsoft\\blabla', 859 | exists: false, 860 | value: '', 861 | }]) 862 | 863 | done() 864 | }) 865 | }) 866 | 867 | it('has a streaming interface', function(done) { 868 | const results = [] 869 | const stream = index.listUnexpandedValues([ 870 | 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 871 | 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 872 | 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 873 | ]).on('data', function (result) { 874 | results.push(result) 875 | }).on('end', function () { 876 | results.should.deepEqual([{ 877 | path: 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 878 | exists: true, 879 | value: '%USERPROFILE%\\AppData\\Roaming', 880 | }, 881 | { 882 | path: 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 883 | exists: true, 884 | value: '%USERPROFILE%\\AppData\\Roaming', 885 | }, 886 | { 887 | path: 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', 888 | exists: true, 889 | value: '%USERPROFILE%\\AppData\\Roaming', 890 | }]) 891 | 892 | done() 893 | }) 894 | }) 895 | }) 896 | }) 897 | -------------------------------------------------------------------------------- /winerrors/generatedErrorObjects.js: -------------------------------------------------------------------------------- 1 | /* global errors */ 2 | /* eslint-disable max-len */ 3 | 4 | var e0 = new Error('wbemErrFailed') 5 | e0.description = 'The call failed.' 6 | e0.code = 2147749889 7 | errors[2147749889] = e0 8 | var e1 = new Error('wbemErrNotFound') 9 | e1.description = 'The object could not be found.' 10 | e1.code = 2147749890 11 | errors[2147749890] = e1 12 | var e2 = new Error('wbemErrAccessDenied') 13 | e2.description = 'The current user does not have permission to perform the action.' 14 | e2.code = 2147749891 15 | errors[2147749891] = e2 16 | var e3 = new Error('wbemErrProviderFailure') 17 | e3.description = 'The provider has failed at some time other than during initialization.' 18 | e3.code = 2147749892 19 | errors[2147749892] = e3 20 | var e4 = new Error('wbemErrTypeMismatch') 21 | e4.description = 'A type mismatch occurred.' 22 | e4.code = 2147749893 23 | errors[2147749893] = e4 24 | var e5 = new Error('wbemErrOutOfMemory') 25 | e5.description = 'There was not enough memory for the operation.' 26 | e5.code = 2147749894 27 | errors[2147749894] = e5 28 | var e6 = new Error('wbemErrInvalidContext') 29 | e6.description = 'The SWbemNamedValue object is not valid.' 30 | e6.code = 2147749895 31 | errors[2147749895] = e6 32 | var e7 = new Error('wbemErrInvalidParameter') 33 | e7.description = 'One of the parameters to the call is not correct.' 34 | e7.code = 2147749896 35 | errors[2147749896] = e7 36 | var e8 = new Error('wbemErrNotAvailable') 37 | e8.description = 'The resource, typically a remote server, is not currently available.' 38 | e8.code = 2147749897 39 | errors[2147749897] = e8 40 | var e9 = new Error('wbemErrCriticalError') 41 | e9.description = 'An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support.' 42 | e9.code = 2147749898 43 | errors[2147749898] = e9 44 | var e10 = new Error('wbemErrInvalidStream') 45 | e10.description = 'One or more network packets were corrupted during a remote session.' 46 | e10.code = 2147749899 47 | errors[2147749899] = e10 48 | var e11 = new Error('wbemErrNotSupported') 49 | e11.description = 'The feature or operation is not supported.' 50 | e11.code = 2147749900 51 | errors[2147749900] = e11 52 | var e12 = new Error('wbemErrInvalidSuperclass') 53 | e12.description = 'The parent class specified is not valid.' 54 | e12.code = 2147749901 55 | errors[2147749901] = e12 56 | var e13 = new Error('wbemErrInvalidNamespace') 57 | e13.description = 'The namespace specified could not be found.' 58 | e13.code = 2147749902 59 | errors[2147749902] = e13 60 | var e14 = new Error('wbemErrInvalidObject') 61 | e14.description = 'The specified instance is not valid.' 62 | e14.code = 2147749903 63 | errors[2147749903] = e14 64 | var e15 = new Error('wbemErrInvalidClass') 65 | e15.description = 'The specified class is not valid.' 66 | e15.code = 2147749904 67 | errors[2147749904] = e15 68 | var e16 = new Error('wbemErrProviderNotFound') 69 | e16.description = 'A provider referenced in the schema does not have a corresponding registration.' 70 | e16.code = 2147749905 71 | errors[2147749905] = e16 72 | var e17 = new Error('wbemErrInvalidProviderRegistration') 73 | e17.description = 'A provider referenced in the schema has an incorrect or incomplete registration. This error may be caused by a missing pragma namespace command in the MOF file used to register the provider, resulting in the provider being registered in the wrong WMI namespace. This error may also be caused by a corrupt repository, which may be fixed by deleting it and recompiling the MOF files.' 74 | e17.code = 2147749906 75 | errors[2147749906] = e17 76 | var e18 = new Error('wbemErrProviderLoadFailure') 77 | e18.description = 'COM cannot locate a provider referenced in the schema. This error may be caused by any of the following:' 78 | e18.code = 2147749907 79 | errors[2147749907] = e18 80 | var e19 = new Error('wbemErrInitializationFailure') 81 | e19.description = 'A component, such as a provider, failed to initialize for internal reasons.' 82 | e19.code = 2147749908 83 | errors[2147749908] = e19 84 | var e20 = new Error('wbemErrTransportFailure') 85 | e20.description = 'A networking error occurred, preventing normal operation.' 86 | e20.code = 2147749909 87 | errors[2147749909] = e20 88 | var e21 = new Error('wbemErrInvalidOperation') 89 | e21.description = 'The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties.' 90 | e21.code = 2147749910 91 | errors[2147749910] = e21 92 | var e22 = new Error('wbemErrInvalidQuery') 93 | e22.description = 'The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties.' 94 | e22.code = 2147749911 95 | errors[2147749911] = e22 96 | var e23 = new Error('wbemErrInvalidQueryType') 97 | e23.description = 'The requested query language is not supported.' 98 | e23.code = 2147749912 99 | errors[2147749912] = e23 100 | var e24 = new Error('wbemErrAlreadyExists') 101 | e24.description = 'In a put operation, the wbemChangeFlagCreateOnly flag was specified, but the instance already exists.' 102 | e24.code = 2147749913 103 | errors[2147749913] = e24 104 | var e25 = new Error('wbemErrOverrideNotAllowed') 105 | e25.description = 'It is not possible to perform the add operation on this qualifier because the owning object does not permit overrides.' 106 | e25.code = 2147749914 107 | errors[2147749914] = e25 108 | var e26 = new Error('wbemErrPropagatedQualifier') 109 | e26.description = 'The user attempted to delete a qualifier that was not owned. The qualifier was inherited from a parent class.' 110 | e26.code = 2147749915 111 | errors[2147749915] = e26 112 | var e27 = new Error('wbemErrPropagatedProperty') 113 | e27.description = 'The user attempted to delete a property that was not owned. The property was inherited from a parent class.' 114 | e27.code = 2147749916 115 | errors[2147749916] = e27 116 | var e28 = new Error('wbemErrUnexpected') 117 | e28.description = 'The client made an unexpected and illegal sequence of calls, such as calling EndEnumeration before calling BeginEnumeration.' 118 | e28.code = 2147749917 119 | errors[2147749917] = e28 120 | var e29 = new Error('wbemErrIllegalOperation') 121 | e29.description = 'The user requested an illegal operation, such as spawning a class from an instance.' 122 | e29.code = 2147749918 123 | errors[2147749918] = e29 124 | var e30 = new Error('wbemErrCannotBeKey') 125 | e30.description = 'There was an illegal attempt to specify a key qualifier on a property that cannot be a key. The keys are specified in the class definition for an object, and cannot be altered on a per-instance basis.' 126 | e30.code = 2147749919 127 | errors[2147749919] = e30 128 | var e31 = new Error('wbemErrIncompleteClass') 129 | e31.description = 'The current object is not a valid class definition. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_.' 130 | e31.code = 2147749920 131 | errors[2147749920] = e31 132 | var e32 = new Error('wbemErrInvalidSyntax') 133 | e32.description = 'The syntax of an input parameter is incorrect for the applicable data structure. For example, when a CIM datetime structure does not have the correct format when passed to SWbemDateTime.SetFileTime.' 134 | e32.code = 2147749921 135 | errors[2147749921] = e32 136 | var e33 = new Error('wbemErrNondecoratedObject') 137 | e33.description = 'Reserved for future use.' 138 | e33.code = 2147749922 139 | errors[2147749922] = e33 140 | var e34 = new Error('wbemErrReadOnly') 141 | e34.description = 'The property that you are attempting to modify is read-only.' 142 | e34.code = 2147749923 143 | errors[2147749923] = e34 144 | var e35 = new Error('wbemErrProviderNotCapable') 145 | e35.description = 'The provider cannot perform the requested operation. This would include a query that is too complex, retrieving an instance, creating or updating a class, deleting a class, or enumerating a class.' 146 | e35.code = 2147749924 147 | errors[2147749924] = e35 148 | var e36 = new Error('wbemErrClassHasChildren') 149 | e36.description = 'An attempt was made to make a change that would invalidate a subclass.' 150 | e36.code = 2147749925 151 | errors[2147749925] = e36 152 | var e37 = new Error('wbemErrClassHasInstances') 153 | e37.description = 'An attempt has been made to delete or modify a class that has instances.' 154 | e37.code = 2147749926 155 | errors[2147749926] = e37 156 | var e38 = new Error('wbemErrQueryNotImplemented') 157 | e38.description = 'Reserved for future use.' 158 | e38.code = 2147749927 159 | errors[2147749927] = e38 160 | var e39 = new Error('wbemErrIllegalNull') 161 | e39.description = 'A value of Nothing was specified for a property that may not be Nothing, such as one that is marked by a Key, Indexed, or Not_Null qualifier.' 162 | e39.code = 2147749928 163 | errors[2147749928] = e39 164 | var e40 = new Error('wbemErrInvalidQualifierType') 165 | e40.description = 'The CIM type specified for a property is not valid.' 166 | e40.code = 2147749929 167 | errors[2147749929] = e40 168 | var e41 = new Error('wbemErrInvalidPropertyType') 169 | e41.description = 'The CIM type specified for a property is not valid.' 170 | e41.code = 2147749930 171 | errors[2147749930] = e41 172 | var e42 = new Error('wbemErrValueOutOfRange') 173 | e42.description = 'The request was made with an out-of-range value, or is incompatible with the type.' 174 | e42.code = 2147749931 175 | errors[2147749931] = e42 176 | var e43 = new Error('wbemErrCannotBeSingleton') 177 | e43.description = 'An illegal attempt was made to make a class singleton, such as when the class is derived from a non-singleton class.' 178 | e43.code = 2147749932 179 | errors[2147749932] = e43 180 | var e44 = new Error('wbemErrInvalidCimType') 181 | e44.description = 'The CIM type specified is not valid.' 182 | e44.code = 2147749933 183 | errors[2147749933] = e44 184 | var e45 = new Error('wbemErrInvalidMethod') 185 | e45.description = 'The requested method is not available.' 186 | e45.code = 2147749934 187 | errors[2147749934] = e45 188 | var e46 = new Error('wbemErrInvalidMethodParameters') 189 | e46.description = 'The parameters provided for the method are not valid.' 190 | e46.code = 2147749935 191 | errors[2147749935] = e46 192 | var e47 = new Error('wbemErrSystemProperty') 193 | e47.description = 'There was an attempt to get qualifiers on a system property.' 194 | e47.code = 2147749936 195 | errors[2147749936] = e47 196 | var e48 = new Error('wbemErrInvalidProperty') 197 | e48.description = 'The property type is not recognized.' 198 | e48.code = 2147749937 199 | errors[2147749937] = e48 200 | var e49 = new Error('wbemErrCallCancelled') 201 | e49.description = 'An asynchronous process has been canceled internally or by the user. Note that due to the timing and nature of the asynchronous operation the operation may not have been truly canceled.' 202 | e49.code = 2147749938 203 | errors[2147749938] = e49 204 | var e50 = new Error('wbemErrShuttingDown') 205 | e50.description = 'The user has requested an operation while WMI is in the process of shutting down.' 206 | e50.code = 2147749939 207 | errors[2147749939] = e50 208 | var e51 = new Error('wbemErrPropagatedMethod') 209 | e51.description = 'An attempt was made to reuse an existing method name from a parent class, and the signatures did not match.' 210 | e51.code = 2147749940 211 | errors[2147749940] = e51 212 | var e52 = new Error('wbemErrUnsupportedParameter') 213 | e52.description = 'One or more parameter values, such as a query text, is too complex or unsupported. WMI is therefore requested to retry the operation with simpler parameters.' 214 | e52.code = 2147749941 215 | errors[2147749941] = e52 216 | var e53 = new Error('wbemErrMissingParameter') 217 | e53.description = 'A parameter was missing from the method call.' 218 | e53.code = 2147749942 219 | errors[2147749942] = e53 220 | var e54 = new Error('wbemErrInvalidParameterId') 221 | e54.description = 'A method parameter has an ID qualifier that is not valid.' 222 | e54.code = 2147749943 223 | errors[2147749943] = e54 224 | var e55 = new Error('wbemErrNonConsecutiveParameterIds') 225 | e55.description = 'One or more of the method parameters have ID qualifiers that are out of sequence.' 226 | e55.code = 2147749944 227 | errors[2147749944] = e55 228 | var e56 = new Error('wbemErrParameterIdOnRetval') 229 | e56.description = 'The return value for a method has an ID qualifier.' 230 | e56.code = 2147749945 231 | errors[2147749945] = e56 232 | var e57 = new Error('wbemErrInvalidObjectPath') 233 | e57.description = 'The specified object path was not valid.' 234 | e57.code = 2147749946 235 | errors[2147749946] = e57 236 | var e58 = new Error('wbemErrOutOfDiskSpace') 237 | e58.description = 'Windows Server 2003: Disk is out of space or the 4 GB limit on WMI repository (CIM repository) size is reached.' 238 | e58.code = 2147749947 239 | errors[2147749947] = e58 240 | var e59 = new Error('wbemErrBufferTooSmall') 241 | e59.description = 'The supplied buffer was too small to hold all the objects in the enumerator or to read a string property.' 242 | e59.code = 2147749948 243 | errors[2147749948] = e59 244 | var e60 = new Error('wbemErrUnsupportedPutExtension') 245 | e60.description = 'The provider does not support the requested put operation.' 246 | e60.code = 2147749949 247 | errors[2147749949] = e60 248 | var e61 = new Error('wbemErrUnknownObjectType') 249 | e61.description = 'An object with an incorrect type or version was encountered during marshaling.' 250 | e61.code = 2147749950 251 | errors[2147749950] = e61 252 | var e62 = new Error('wbemErrUnknownPacketType') 253 | e62.description = 'A packet with an incorrect type or version was encountered during marshaling.' 254 | e62.code = 2147749951 255 | errors[2147749951] = e62 256 | var e63 = new Error('wbemErrMarshalVersionMismatch') 257 | e63.description = 'The packet has an unsupported version.' 258 | e63.code = 2147749952 259 | errors[2147749952] = e63 260 | var e64 = new Error('wbemErrMarshalInvalidSignature') 261 | e64.description = 'The packet appears to be corrupted.' 262 | e64.code = 2147749953 263 | errors[2147749953] = e64 264 | var e65 = new Error('wbemErrInvalidQualifier') 265 | e65.description = 'An attempt has been made to mismatch qualifiers, such as putting [key] on an object instead of a property.' 266 | e65.code = 2147749954 267 | errors[2147749954] = e65 268 | var e66 = new Error('wbemErrInvalidDuplicateParameter') 269 | e66.description = 'A duplicate parameter has been declared in a CIM method.' 270 | e66.code = 2147749955 271 | errors[2147749955] = e66 272 | var e67 = new Error('wbemErrTooMuchData') 273 | e67.description = 'Reserved for future use.' 274 | e67.code = 2147749956 275 | errors[2147749956] = e67 276 | var e68 = new Error('wbemErrServerTooBusy') 277 | e68.description = 'A call to IWbemObjectSink::Indicate has failed. The provider may choose to refire the event.' 278 | e68.code = 2147749957 279 | errors[2147749957] = e68 280 | var e69 = new Error('wbemErrInvalidFlavor') 281 | e69.description = 'The specified flavor was not valid.' 282 | e69.code = 2147749958 283 | errors[2147749958] = e69 284 | var e70 = new Error('wbemErrCircularReference') 285 | e70.description = 'An attempt has been made to create a reference that is circular (for example, deriving a class from itself).' 286 | e70.code = 2147749959 287 | errors[2147749959] = e70 288 | var e71 = new Error('wbemErrUnsupportedClassUpdate') 289 | e71.description = 'The specified class is not supported.' 290 | e71.code = 2147749960 291 | errors[2147749960] = e71 292 | var e72 = new Error('wbemErrCannotChangeKeyInheritance') 293 | e72.description = 'An attempt was made to change a key when instances or subclasses are already using the key.' 294 | e72.code = 2147749961 295 | errors[2147749961] = e72 296 | var e73 = new Error('wbemErrCannotChangeIndexInheritance') 297 | e73.description = 'An attempt was made to change an index when instances or subclasses are already using the index.' 298 | e73.code = 2147749968 299 | errors[2147749968] = e73 300 | var e74 = new Error('wbemErrTooManyProperties') 301 | e74.description = 'An attempt was made to create more properties than the current version of the class supports.' 302 | e74.code = 2147749969 303 | errors[2147749969] = e74 304 | var e75 = new Error('wbemErrUpdateTypeMismatch') 305 | e75.description = 'A property was redefined with a conflicting type in a derived class.' 306 | e75.code = 2147749970 307 | errors[2147749970] = e75 308 | var e76 = new Error('wbemErrUpdateOverrideNotAllowed') 309 | e76.description = 'An attempt was made in a derived class to override a non-overrideable qualifier.' 310 | e76.code = 2147749971 311 | errors[2147749971] = e76 312 | var e77 = new Error('wbemErrUpdatePropagatedMethod') 313 | e77.description = 'A method was redeclared with a conflicting signature in a derived class.' 314 | e77.code = 2147749972 315 | errors[2147749972] = e77 316 | var e78 = new Error('wbemErrMethodNotImplemented') 317 | e78.description = 'An attempt was made to execute a method not marked with [implemented] in any relevant class.' 318 | e78.code = 2147749973 319 | errors[2147749973] = e78 320 | var e79 = new Error('wbemErrMethodDisabled') 321 | e79.description = 'An attempt was made to execute a method marked with [disabled].' 322 | e79.code = 2147749974 323 | errors[2147749974] = e79 324 | var e80 = new Error('wbemErrRefresherBusy') 325 | e80.description = 'The refresher is busy with another operation.' 326 | e80.code = 2147749975 327 | errors[2147749975] = e80 328 | var e81 = new Error('wbemErrUnparsableQuery') 329 | e81.description = 'The filtering query is syntactically not valid.' 330 | e81.code = 2147749976 331 | errors[2147749976] = e81 332 | var e82 = new Error('wbemErrNotEventClass') 333 | e82.description = 'The FROM clause of a filtering query references a class that is not an event class (not derived from __Event).' 334 | e82.code = 2147749977 335 | errors[2147749977] = e82 336 | var e83 = new Error('wbemErrMissingGroupWithin') 337 | e83.description = 'A GROUP BY clause was used without the corresponding GROUP WITHIN clause.' 338 | e83.code = 2147749978 339 | errors[2147749978] = e83 340 | var e84 = new Error('wbemErrMissingAggregationList') 341 | e84.description = 'A GROUP BY clause was used. Aggregation on all properties is not supported.' 342 | e84.code = 2147749979 343 | errors[2147749979] = e84 344 | var e85 = new Error('wbemErrPropertyNotAnObject') 345 | e85.description = 'Dot notation was used on a property that is not an embedded object.' 346 | e85.code = 2147749980 347 | errors[2147749980] = e85 348 | var e86 = new Error('wbemErrAggregatingByObject') 349 | e86.description = 'A GROUP BY clause references a property that is an embedded object without using dot notation.' 350 | e86.code = 2147749981 351 | errors[2147749981] = e86 352 | var e87 = new Error('wbemErrUninterpretableProviderQuery') 353 | e87.description = 'An event provider registration query ( __EventProviderRegistration) did not specify the classes for which events were provided.' 354 | e87.code = 2147749983 355 | errors[2147749983] = e87 356 | var e88 = new Error('wbemErrBackupRestoreWinmgmtRunning') 357 | e88.description = 'An request was made to back up or restore the repository while WMI was using it.' 358 | e88.code = 2147749984 359 | errors[2147749984] = e88 360 | var e89 = new Error('wbemErrQueueOverflow') 361 | e89.description = 'The asynchronous delivery queue overflowed due to the event consumer being too slow.' 362 | e89.code = 2147749985 363 | errors[2147749985] = e89 364 | var e90 = new Error('wbemErrPrivilegeNotHeld') 365 | e90.description = 'The operation failed because the client did not have the necessary security privilege.' 366 | e90.code = 2147749986 367 | errors[2147749986] = e90 368 | var e91 = new Error('wbemErrInvalidOperator') 369 | e91.description = 'The operator is not valid for this property type.' 370 | e91.code = 2147749987 371 | errors[2147749987] = e91 372 | var e92 = new Error('wbemErrLocalCredentials') 373 | e92.description = 'The user specified a username, password or authority for a local connection. The user must use a blank username/password and rely on default security.' 374 | e92.code = 2147749988 375 | errors[2147749988] = e92 376 | var e93 = new Error('wbemErrCannotBeAbstract') 377 | e93.description = 'The class was made abstract when its parent class is not abstract.' 378 | e93.code = 2147749989 379 | errors[2147749989] = e93 380 | var e94 = new Error('wbemErrAmendedObject') 381 | e94.description = 'An amended object was put without the wbemFlagUseAmendedQualifiers flag being specified.' 382 | e94.code = 2147749990 383 | errors[2147749990] = e94 384 | var e95 = new Error('wbemErrClientTooSlow') 385 | e95.description = 'Windows Server 2003: The client was not retrieving objects quickly enough from an enumeration. This constant is returned when a client creates an enumeration object but does not retrieve objects from the enumerator in a timely fashion, causing the enumerator\'s object caches to get backed up.' 386 | e95.code = 2147749991 387 | errors[2147749991] = e95 388 | var e96 = new Error('wbemErrNullSecurityDescriptor') 389 | e96.description = 'Windows Server 2003: A null security descriptor was used.' 390 | e96.code = 2147749992 391 | errors[2147749992] = e96 392 | var e97 = new Error('wbemErrTimeout') 393 | e97.description = 'Windows Server 2003: The operation timed out.' 394 | e97.code = 2147749993 395 | errors[2147749993] = e97 396 | var e98 = new Error('wbemErrInvalidAssociation') 397 | e98.description = 'Windows Server 2003: The association being used is not valid.' 398 | e98.code = 2147749994 399 | errors[2147749994] = e98 400 | var e99 = new Error('wbemErrAmbiguousOperation') 401 | e99.description = 'Windows Server 2003: The operation was ambiguous.' 402 | e99.code = 2147749995 403 | errors[2147749995] = e99 404 | var e100 = new Error('wbemErrQuotaViolation') 405 | e100.description = 'Windows Server 2003: WMI is taking up too much memory. This could be caused either by low memory availability or excessive memory consumption by WMI.' 406 | e100.code = 2147749996 407 | errors[2147749996] = e100 408 | var e101 = new Error('wbemErrTransactionConflict') 409 | e101.description = 'Windows Server 2003: The operation resulted in a transaction conflict.' 410 | e101.code = 2147749997 411 | errors[2147749997] = e101 412 | var e102 = new Error('wbemErrForcedRollback') 413 | e102.description = 'Windows Server 2003: The transaction forced a rollback.' 414 | e102.code = 2147749998 415 | errors[2147749998] = e102 416 | var e103 = new Error('wbemErrUnsupportedLocale') 417 | e103.description = 'Windows Server 2003: The locale used in the call is not supported.' 418 | e103.code = 2147749999 419 | errors[2147749999] = e103 420 | var e104 = new Error('wbemErrHandleOutOfDate') 421 | e104.description = 'Windows Server 2003: The object handle is out of date.' 422 | e104.code = 2147750000 423 | errors[2147750000] = e104 424 | var e105 = new Error('wbemErrConnectionFailed') 425 | e105.description = 'Windows Server 2003: Indicates that the connection to the SQL database failed.' 426 | e105.code = 2147750001 427 | errors[2147750001] = e105 428 | var e106 = new Error('wbemErrInvalidHandleRequest') 429 | e106.description = 'Windows Server 2003: The handle request was not valid.' 430 | e106.code = 2147750002 431 | errors[2147750002] = e106 432 | var e107 = new Error('wbemErrPropertyNameTooWide') 433 | e107.description = 'Windows Server 2003: The property name contains more than 255 characters.' 434 | e107.code = 2147750003 435 | errors[2147750003] = e107 436 | var e108 = new Error('wbemErrClassNameTooWide') 437 | e108.description = 'Windows Server 2003: The class name contains more than 255 characters.' 438 | e108.code = 2147750004 439 | errors[2147750004] = e108 440 | var e109 = new Error('wbemErrMethodNameTooWide') 441 | e109.description = 'Windows Server 2003: The method name contains more than 255 characters.' 442 | e109.code = 2147750005 443 | errors[2147750005] = e109 444 | var e110 = new Error('wbemErrQualifierNameTooWide') 445 | e110.description = 'Windows Server 2003: The qualifier name contains more than 255 characters.' 446 | e110.code = 2147750006 447 | errors[2147750006] = e110 448 | var e111 = new Error('wbemErrRerunCommand') 449 | e111.description = 'Windows Server 2003: Indicates that an SQL command should be rerun because there is a deadlock in SQL. This can be returned only when data is being stored in an SQL database.' 450 | e111.code = 2147750007 451 | errors[2147750007] = e111 452 | var e112 = new Error('wbemErrDatabaseVerMismatch') 453 | e112.description = 'Windows Server 2003: The database version does not match the version that the repository driver processes.' 454 | e112.code = 2147750008 455 | errors[2147750008] = e112 456 | var e113 = new Error('wbemErrVetoDelete') 457 | e113.description = 'Windows Server 2003: WMI cannot do the delete operation because the provider does not allow it.' 458 | e113.code = 2147750010 459 | errors[2147750010] = e113 460 | var e114 = new Error('wbemErrVetoPut') 461 | e114.description = 'Windows Server 2003: WMI cannot do the put operation because the provider does not allow it.' 462 | e114.code = 2147750010 463 | errors[2147750010] = e114 464 | var e115 = new Error('wbemErrInvalidLocale') 465 | e115.description = 'Windows Server 2003: The specified locale identifier was not valid for the operation.' 466 | e115.code = 2147750016 467 | errors[2147750016] = e115 468 | var e116 = new Error('wbemErrProviderSuspended') 469 | e116.description = 'Windows Server 2003: The provider is suspended.' 470 | e116.code = 2147750017 471 | errors[2147750017] = e116 472 | var e117 = new Error('wbemErrSynchronizationRequired') 473 | e117.description = 'Windows Server 2003: The object must be committed and retrieved again before the requested operation can succeed. This constant is returned when an object must be committed and re-retrieved to see the property value.' 474 | e117.code = 2147750018 475 | errors[2147750018] = e117 476 | var e118 = new Error('wbemErrNoSchema') 477 | e118.description = 'Windows Server 2003: The operation cannot be completed because no schema is available.' 478 | e118.code = 2147750019 479 | errors[2147750019] = e118 480 | var e119 = new Error('wbemErrProviderAlreadyRegistered') 481 | e119.description = 'Windows Server 2003: The provider registration cannot be done because the provider is already registered.' 482 | e119.code = 2147750020 483 | errors[2147750020] = e119 484 | var e120 = new Error('wbemErrProviderNotRegistered') 485 | e120.description = 'Windows Server 2003: The provider for the requested data is not registered.' 486 | e120.code = 2147750021 487 | errors[2147750021] = e120 488 | var e121 = new Error('wbemErrFatalTransportError') 489 | e121.description = 'Windows Server 2003: A fatal transport error occurred and other transport will not be attempted.' 490 | e121.code = 2147750022 491 | errors[2147750022] = e121 492 | var e122 = new Error('wbemErrEncryptedConnectionRequired') 493 | e122.description = 'Windows Server 2003: The client connection to WINMGMT must be encrypted for this operation. The IWbemServices proxy security settings should be adjusted and the operation retried.' 494 | e122.code = 2147750023 495 | errors[2147750023] = e122 496 | var e123 = new Error('wbemErrRegistrationTooBroad') 497 | e123.description = 'Windows Server 2003: The provider registration overlaps with the system event domain.' 498 | e123.code = 2147753985 499 | errors[2147753985] = e123 500 | var e124 = new Error('wbemErrRegistrationTooPrecise') 501 | e124.description = 'Windows Server 2003: A WITHIN clause was not used in this query.' 502 | e124.code = 2147753986 503 | errors[2147753986] = e124 504 | var e125 = new Error('wbemErrTimedout') 505 | e125.description = 'Windows Server 2003: Automation-specific error.' 506 | e125.code = 2147758081 507 | errors[2147758081] = e125 508 | var e126 = new Error('wbemErrResetToDefault') 509 | e126.description = 'undefined' 510 | e126.code = 2147758082 511 | errors[2147758082] = e126 512 | -------------------------------------------------------------------------------- /errors.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | 3 | var errors = {} 4 | 5 | errors[25121] = new Error('missing arguments') 6 | errors[25121].code = 25121 7 | 8 | errors[25122] = new Error('unsupported hive') 9 | errors[25122].code = 25122 10 | 11 | errors[25123] = new Error('expected to have groups of 4 arguments for each value that is written to the registry') 12 | errors[25123].code = 25123 13 | 14 | errors[25124] = new Error('missing or invalid architecture from arguments, use "A" (agnostic), "S" (specific), "32" or "64"') 15 | errors[25124].code = 25124 16 | 17 | errors[25125] = new Error('missing OSArchitecture global. Forgot to load util.vbs? submit an issue asap with steps to recreate') 18 | errors[25125].code = 25125 19 | 20 | errors[25126] = new Error('invalid os architecture detected') 21 | errors[25126].code = 25126 22 | 23 | errors[25127] = new Error('empty line written to vbscript stdin') 24 | errors[25127].code = 25127 25 | 26 | 27 | //TODO: this is an error that is caused by trying to create a registry key somewhere I dont have permissions to 28 | // where is the reference for these codes....??? 29 | errors[5] = new Error('access is denied') 30 | errors[5].code = 5 31 | 32 | errors[2] = new Error('registry path does not exist') 33 | errors[2].code = 2 34 | 35 | // *** generated errors ***// 36 | var e0 = new Error('wbemErrFailed') 37 | e0.description = 'The call failed.' 38 | e0.code = 2147749889 39 | errors[2147749889] = e0 40 | var e1 = new Error('wbemErrNotFound') 41 | e1.description = 'The object could not be found.' 42 | e1.code = 2147749890 43 | errors[2147749890] = e1 44 | var e2 = new Error('wbemErrAccessDenied') 45 | e2.description = 'The current user does not have permission to perform the action.' 46 | e2.code = 2147749891 47 | errors[2147749891] = e2 48 | var e3 = new Error('wbemErrProviderFailure') 49 | e3.description = 'The provider has failed at some time other than during initialization.' 50 | e3.code = 2147749892 51 | errors[2147749892] = e3 52 | var e4 = new Error('wbemErrTypeMismatch') 53 | e4.description = 'A type mismatch occurred.' 54 | e4.code = 2147749893 55 | errors[2147749893] = e4 56 | var e5 = new Error('wbemErrOutOfMemory') 57 | e5.description = 'There was not enough memory for the operation.' 58 | e5.code = 2147749894 59 | errors[2147749894] = e5 60 | var e6 = new Error('wbemErrInvalidContext') 61 | e6.description = 'The SWbemNamedValue object is not valid.' 62 | e6.code = 2147749895 63 | errors[2147749895] = e6 64 | var e7 = new Error('wbemErrInvalidParameter') 65 | e7.description = 'One of the parameters to the call is not correct.' 66 | e7.code = 2147749896 67 | errors[2147749896] = e7 68 | var e8 = new Error('wbemErrNotAvailable') 69 | e8.description = 'The resource, typically a remote server, is not currently available.' 70 | e8.code = 2147749897 71 | errors[2147749897] = e8 72 | var e9 = new Error('wbemErrCriticalError') 73 | e9.description = 'An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support.' 74 | e9.code = 2147749898 75 | errors[2147749898] = e9 76 | var e10 = new Error('wbemErrInvalidStream') 77 | e10.description = 'One or more network packets were corrupted during a remote session.' 78 | e10.code = 2147749899 79 | errors[2147749899] = e10 80 | var e11 = new Error('wbemErrNotSupported') 81 | e11.description = 'The feature or operation is not supported.' 82 | e11.code = 2147749900 83 | errors[2147749900] = e11 84 | var e12 = new Error('wbemErrInvalidSuperclass') 85 | e12.description = 'The parent class specified is not valid.' 86 | e12.code = 2147749901 87 | errors[2147749901] = e12 88 | var e13 = new Error('wbemErrInvalidNamespace') 89 | e13.description = 'The namespace specified could not be found.' 90 | e13.code = 2147749902 91 | errors[2147749902] = e13 92 | var e14 = new Error('wbemErrInvalidObject') 93 | e14.description = 'The specified instance is not valid.' 94 | e14.code = 2147749903 95 | errors[2147749903] = e14 96 | var e15 = new Error('wbemErrInvalidClass') 97 | e15.description = 'The specified class is not valid.' 98 | e15.code = 2147749904 99 | errors[2147749904] = e15 100 | var e16 = new Error('wbemErrProviderNotFound') 101 | e16.description = 'A provider referenced in the schema does not have a corresponding registration.' 102 | e16.code = 2147749905 103 | errors[2147749905] = e16 104 | var e17 = new Error('wbemErrInvalidProviderRegistration') 105 | e17.description = 'A provider referenced in the schema has an incorrect or incomplete registration. This error may be caused by a missing pragma namespace command in the MOF file used to register the provider, resulting in the provider being registered in the wrong WMI namespace. This error may also be caused by a corrupt repository, which may be fixed by deleting it and recompiling the MOF files.' 106 | e17.code = 2147749906 107 | errors[2147749906] = e17 108 | var e18 = new Error('wbemErrProviderLoadFailure') 109 | e18.description = 'COM cannot locate a provider referenced in the schema. This error may be caused by any of the following:' 110 | e18.code = 2147749907 111 | errors[2147749907] = e18 112 | var e19 = new Error('wbemErrInitializationFailure') 113 | e19.description = 'A component, such as a provider, failed to initialize for internal reasons.' 114 | e19.code = 2147749908 115 | errors[2147749908] = e19 116 | var e20 = new Error('wbemErrTransportFailure') 117 | e20.description = 'A networking error occurred, preventing normal operation.' 118 | e20.code = 2147749909 119 | errors[2147749909] = e20 120 | var e21 = new Error('wbemErrInvalidOperation') 121 | e21.description = 'The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties.' 122 | e21.code = 2147749910 123 | errors[2147749910] = e21 124 | var e22 = new Error('wbemErrInvalidQuery') 125 | e22.description = 'The requested operation is not valid. This error usually applies to invalid attempts to delete classes or properties.' 126 | e22.code = 2147749911 127 | errors[2147749911] = e22 128 | var e23 = new Error('wbemErrInvalidQueryType') 129 | e23.description = 'The requested query language is not supported.' 130 | e23.code = 2147749912 131 | errors[2147749912] = e23 132 | var e24 = new Error('wbemErrAlreadyExists') 133 | e24.description = 'In a put operation, the wbemChangeFlagCreateOnly flag was specified, but the instance already exists.' 134 | e24.code = 2147749913 135 | errors[2147749913] = e24 136 | var e25 = new Error('wbemErrOverrideNotAllowed') 137 | e25.description = 'It is not possible to perform the add operation on this qualifier because the owning object does not permit overrides.' 138 | e25.code = 2147749914 139 | errors[2147749914] = e25 140 | var e26 = new Error('wbemErrPropagatedQualifier') 141 | e26.description = 'The user attempted to delete a qualifier that was not owned. The qualifier was inherited from a parent class.' 142 | e26.code = 2147749915 143 | errors[2147749915] = e26 144 | var e27 = new Error('wbemErrPropagatedProperty') 145 | e27.description = 'The user attempted to delete a property that was not owned. The property was inherited from a parent class.' 146 | e27.code = 2147749916 147 | errors[2147749916] = e27 148 | var e28 = new Error('wbemErrUnexpected') 149 | e28.description = 'The client made an unexpected and illegal sequence of calls, such as calling EndEnumeration before calling BeginEnumeration.' 150 | e28.code = 2147749917 151 | errors[2147749917] = e28 152 | var e29 = new Error('wbemErrIllegalOperation') 153 | e29.description = 'The user requested an illegal operation, such as spawning a class from an instance.' 154 | e29.code = 2147749918 155 | errors[2147749918] = e29 156 | var e30 = new Error('wbemErrCannotBeKey') 157 | e30.description = 'There was an illegal attempt to specify a key qualifier on a property that cannot be a key. The keys are specified in the class definition for an object, and cannot be altered on a per-instance basis.' 158 | e30.code = 2147749919 159 | errors[2147749919] = e30 160 | var e31 = new Error('wbemErrIncompleteClass') 161 | e31.description = 'The current object is not a valid class definition. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_.' 162 | e31.code = 2147749920 163 | errors[2147749920] = e31 164 | var e32 = new Error('wbemErrInvalidSyntax') 165 | e32.description = 'The syntax of an input parameter is incorrect for the applicable data structure. For example, when a CIM datetime structure does not have the correct format when passed to SWbemDateTime.SetFileTime.' 166 | e32.code = 2147749921 167 | errors[2147749921] = e32 168 | var e33 = new Error('wbemErrNondecoratedObject') 169 | e33.description = 'Reserved for future use.' 170 | e33.code = 2147749922 171 | errors[2147749922] = e33 172 | var e34 = new Error('wbemErrReadOnly') 173 | e34.description = 'The property that you are attempting to modify is read-only.' 174 | e34.code = 2147749923 175 | errors[2147749923] = e34 176 | var e35 = new Error('wbemErrProviderNotCapable') 177 | e35.description = 'The provider cannot perform the requested operation. This would include a query that is too complex, retrieving an instance, creating or updating a class, deleting a class, or enumerating a class.' 178 | e35.code = 2147749924 179 | errors[2147749924] = e35 180 | var e36 = new Error('wbemErrClassHasChildren') 181 | e36.description = 'An attempt was made to make a change that would invalidate a subclass.' 182 | e36.code = 2147749925 183 | errors[2147749925] = e36 184 | var e37 = new Error('wbemErrClassHasInstances') 185 | e37.description = 'An attempt has been made to delete or modify a class that has instances.' 186 | e37.code = 2147749926 187 | errors[2147749926] = e37 188 | var e38 = new Error('wbemErrQueryNotImplemented') 189 | e38.description = 'Reserved for future use.' 190 | e38.code = 2147749927 191 | errors[2147749927] = e38 192 | var e39 = new Error('wbemErrIllegalNull') 193 | e39.description = 'A value of Nothing was specified for a property that may not be Nothing, such as one that is marked by a Key, Indexed, or Not_Null qualifier.' 194 | e39.code = 2147749928 195 | errors[2147749928] = e39 196 | var e40 = new Error('wbemErrInvalidQualifierType') 197 | e40.description = 'The CIM type specified for a property is not valid.' 198 | e40.code = 2147749929 199 | errors[2147749929] = e40 200 | var e41 = new Error('wbemErrInvalidPropertyType') 201 | e41.description = 'The CIM type specified for a property is not valid.' 202 | e41.code = 2147749930 203 | errors[2147749930] = e41 204 | var e42 = new Error('wbemErrValueOutOfRange') 205 | e42.description = 'The request was made with an out-of-range value, or is incompatible with the type.' 206 | e42.code = 2147749931 207 | errors[2147749931] = e42 208 | var e43 = new Error('wbemErrCannotBeSingleton') 209 | e43.description = 'An illegal attempt was made to make a class singleton, such as when the class is derived from a non-singleton class.' 210 | e43.code = 2147749932 211 | errors[2147749932] = e43 212 | var e44 = new Error('wbemErrInvalidCimType') 213 | e44.description = 'The CIM type specified is not valid.' 214 | e44.code = 2147749933 215 | errors[2147749933] = e44 216 | var e45 = new Error('wbemErrInvalidMethod') 217 | e45.description = 'The requested method is not available.' 218 | e45.code = 2147749934 219 | errors[2147749934] = e45 220 | var e46 = new Error('wbemErrInvalidMethodParameters') 221 | e46.description = 'The parameters provided for the method are not valid.' 222 | e46.code = 2147749935 223 | errors[2147749935] = e46 224 | var e47 = new Error('wbemErrSystemProperty') 225 | e47.description = 'There was an attempt to get qualifiers on a system property.' 226 | e47.code = 2147749936 227 | errors[2147749936] = e47 228 | var e48 = new Error('wbemErrInvalidProperty') 229 | e48.description = 'The property type is not recognized.' 230 | e48.code = 2147749937 231 | errors[2147749937] = e48 232 | var e49 = new Error('wbemErrCallCancelled') 233 | e49.description = 'An asynchronous process has been canceled internally or by the user. Note that due to the timing and nature of the asynchronous operation the operation may not have been truly canceled.' 234 | e49.code = 2147749938 235 | errors[2147749938] = e49 236 | var e50 = new Error('wbemErrShuttingDown') 237 | e50.description = 'The user has requested an operation while WMI is in the process of shutting down.' 238 | e50.code = 2147749939 239 | errors[2147749939] = e50 240 | var e51 = new Error('wbemErrPropagatedMethod') 241 | e51.description = 'An attempt was made to reuse an existing method name from a parent class, and the signatures did not match.' 242 | e51.code = 2147749940 243 | errors[2147749940] = e51 244 | var e52 = new Error('wbemErrUnsupportedParameter') 245 | e52.description = 'One or more parameter values, such as a query text, is too complex or unsupported. WMI is therefore requested to retry the operation with simpler parameters.' 246 | e52.code = 2147749941 247 | errors[2147749941] = e52 248 | var e53 = new Error('wbemErrMissingParameter') 249 | e53.description = 'A parameter was missing from the method call.' 250 | e53.code = 2147749942 251 | errors[2147749942] = e53 252 | var e54 = new Error('wbemErrInvalidParameterId') 253 | e54.description = 'A method parameter has an ID qualifier that is not valid.' 254 | e54.code = 2147749943 255 | errors[2147749943] = e54 256 | var e55 = new Error('wbemErrNonConsecutiveParameterIds') 257 | e55.description = 'One or more of the method parameters have ID qualifiers that are out of sequence.' 258 | e55.code = 2147749944 259 | errors[2147749944] = e55 260 | var e56 = new Error('wbemErrParameterIdOnRetval') 261 | e56.description = 'The return value for a method has an ID qualifier.' 262 | e56.code = 2147749945 263 | errors[2147749945] = e56 264 | var e57 = new Error('wbemErrInvalidObjectPath') 265 | e57.description = 'The specified object path was not valid.' 266 | e57.code = 2147749946 267 | errors[2147749946] = e57 268 | var e58 = new Error('wbemErrOutOfDiskSpace') 269 | e58.description = 'Windows Server 2003: Disk is out of space or the 4 GB limit on WMI repository (CIM repository) size is reached.' 270 | e58.code = 2147749947 271 | errors[2147749947] = e58 272 | var e59 = new Error('wbemErrBufferTooSmall') 273 | e59.description = 'The supplied buffer was too small to hold all the objects in the enumerator or to read a string property.' 274 | e59.code = 2147749948 275 | errors[2147749948] = e59 276 | var e60 = new Error('wbemErrUnsupportedPutExtension') 277 | e60.description = 'The provider does not support the requested put operation.' 278 | e60.code = 2147749949 279 | errors[2147749949] = e60 280 | var e61 = new Error('wbemErrUnknownObjectType') 281 | e61.description = 'An object with an incorrect type or version was encountered during marshaling.' 282 | e61.code = 2147749950 283 | errors[2147749950] = e61 284 | var e62 = new Error('wbemErrUnknownPacketType') 285 | e62.description = 'A packet with an incorrect type or version was encountered during marshaling.' 286 | e62.code = 2147749951 287 | errors[2147749951] = e62 288 | var e63 = new Error('wbemErrMarshalVersionMismatch') 289 | e63.description = 'The packet has an unsupported version.' 290 | e63.code = 2147749952 291 | errors[2147749952] = e63 292 | var e64 = new Error('wbemErrMarshalInvalidSignature') 293 | e64.description = 'The packet appears to be corrupted.' 294 | e64.code = 2147749953 295 | errors[2147749953] = e64 296 | var e65 = new Error('wbemErrInvalidQualifier') 297 | e65.description = 'An attempt has been made to mismatch qualifiers, such as putting [key] on an object instead of a property.' 298 | e65.code = 2147749954 299 | errors[2147749954] = e65 300 | var e66 = new Error('wbemErrInvalidDuplicateParameter') 301 | e66.description = 'A duplicate parameter has been declared in a CIM method.' 302 | e66.code = 2147749955 303 | errors[2147749955] = e66 304 | var e67 = new Error('wbemErrTooMuchData') 305 | e67.description = 'Reserved for future use.' 306 | e67.code = 2147749956 307 | errors[2147749956] = e67 308 | var e68 = new Error('wbemErrServerTooBusy') 309 | e68.description = 'A call to IWbemObjectSink::Indicate has failed. The provider may choose to refire the event.' 310 | e68.code = 2147749957 311 | errors[2147749957] = e68 312 | var e69 = new Error('wbemErrInvalidFlavor') 313 | e69.description = 'The specified flavor was not valid.' 314 | e69.code = 2147749958 315 | errors[2147749958] = e69 316 | var e70 = new Error('wbemErrCircularReference') 317 | e70.description = 'An attempt has been made to create a reference that is circular (for example, deriving a class from itself).' 318 | e70.code = 2147749959 319 | errors[2147749959] = e70 320 | var e71 = new Error('wbemErrUnsupportedClassUpdate') 321 | e71.description = 'The specified class is not supported.' 322 | e71.code = 2147749960 323 | errors[2147749960] = e71 324 | var e72 = new Error('wbemErrCannotChangeKeyInheritance') 325 | e72.description = 'An attempt was made to change a key when instances or subclasses are already using the key.' 326 | e72.code = 2147749961 327 | errors[2147749961] = e72 328 | var e73 = new Error('wbemErrCannotChangeIndexInheritance') 329 | e73.description = 'An attempt was made to change an index when instances or subclasses are already using the index.' 330 | e73.code = 2147749968 331 | errors[2147749968] = e73 332 | var e74 = new Error('wbemErrTooManyProperties') 333 | e74.description = 'An attempt was made to create more properties than the current version of the class supports.' 334 | e74.code = 2147749969 335 | errors[2147749969] = e74 336 | var e75 = new Error('wbemErrUpdateTypeMismatch') 337 | e75.description = 'A property was redefined with a conflicting type in a derived class.' 338 | e75.code = 2147749970 339 | errors[2147749970] = e75 340 | var e76 = new Error('wbemErrUpdateOverrideNotAllowed') 341 | e76.description = 'An attempt was made in a derived class to override a non-overrideable qualifier.' 342 | e76.code = 2147749971 343 | errors[2147749971] = e76 344 | var e77 = new Error('wbemErrUpdatePropagatedMethod') 345 | e77.description = 'A method was redeclared with a conflicting signature in a derived class.' 346 | e77.code = 2147749972 347 | errors[2147749972] = e77 348 | var e78 = new Error('wbemErrMethodNotImplemented') 349 | e78.description = 'An attempt was made to execute a method not marked with [implemented] in any relevant class.' 350 | e78.code = 2147749973 351 | errors[2147749973] = e78 352 | var e79 = new Error('wbemErrMethodDisabled') 353 | e79.description = 'An attempt was made to execute a method marked with [disabled].' 354 | e79.code = 2147749974 355 | errors[2147749974] = e79 356 | var e80 = new Error('wbemErrRefresherBusy') 357 | e80.description = 'The refresher is busy with another operation.' 358 | e80.code = 2147749975 359 | errors[2147749975] = e80 360 | var e81 = new Error('wbemErrUnparsableQuery') 361 | e81.description = 'The filtering query is syntactically not valid.' 362 | e81.code = 2147749976 363 | errors[2147749976] = e81 364 | var e82 = new Error('wbemErrNotEventClass') 365 | e82.description = 'The FROM clause of a filtering query references a class that is not an event class (not derived from __Event).' 366 | e82.code = 2147749977 367 | errors[2147749977] = e82 368 | var e83 = new Error('wbemErrMissingGroupWithin') 369 | e83.description = 'A GROUP BY clause was used without the corresponding GROUP WITHIN clause.' 370 | e83.code = 2147749978 371 | errors[2147749978] = e83 372 | var e84 = new Error('wbemErrMissingAggregationList') 373 | e84.description = 'A GROUP BY clause was used. Aggregation on all properties is not supported.' 374 | e84.code = 2147749979 375 | errors[2147749979] = e84 376 | var e85 = new Error('wbemErrPropertyNotAnObject') 377 | e85.description = 'Dot notation was used on a property that is not an embedded object.' 378 | e85.code = 2147749980 379 | errors[2147749980] = e85 380 | var e86 = new Error('wbemErrAggregatingByObject') 381 | e86.description = 'A GROUP BY clause references a property that is an embedded object without using dot notation.' 382 | e86.code = 2147749981 383 | errors[2147749981] = e86 384 | var e87 = new Error('wbemErrUninterpretableProviderQuery') 385 | e87.description = 'An event provider registration query ( __EventProviderRegistration) did not specify the classes for which events were provided.' 386 | e87.code = 2147749983 387 | errors[2147749983] = e87 388 | var e88 = new Error('wbemErrBackupRestoreWinmgmtRunning') 389 | e88.description = 'An request was made to back up or restore the repository while WMI was using it.' 390 | e88.code = 2147749984 391 | errors[2147749984] = e88 392 | var e89 = new Error('wbemErrQueueOverflow') 393 | e89.description = 'The asynchronous delivery queue overflowed due to the event consumer being too slow.' 394 | e89.code = 2147749985 395 | errors[2147749985] = e89 396 | var e90 = new Error('wbemErrPrivilegeNotHeld') 397 | e90.description = 'The operation failed because the client did not have the necessary security privilege.' 398 | e90.code = 2147749986 399 | errors[2147749986] = e90 400 | var e91 = new Error('wbemErrInvalidOperator') 401 | e91.description = 'The operator is not valid for this property type.' 402 | e91.code = 2147749987 403 | errors[2147749987] = e91 404 | var e92 = new Error('wbemErrLocalCredentials') 405 | e92.description = 'The user specified a username, password or authority for a local connection. The user must use a blank username/password and rely on default security.' 406 | e92.code = 2147749988 407 | errors[2147749988] = e92 408 | var e93 = new Error('wbemErrCannotBeAbstract') 409 | e93.description = 'The class was made abstract when its parent class is not abstract.' 410 | e93.code = 2147749989 411 | errors[2147749989] = e93 412 | var e94 = new Error('wbemErrAmendedObject') 413 | e94.description = 'An amended object was put without the wbemFlagUseAmendedQualifiers flag being specified.' 414 | e94.code = 2147749990 415 | errors[2147749990] = e94 416 | var e95 = new Error('wbemErrClientTooSlow') 417 | e95.description = 'Windows Server 2003: The client was not retrieving objects quickly enough from an enumeration. This constant is returned when a client creates an enumeration object but does not retrieve objects from the enumerator in a timely fashion, causing the enumerator\'s object caches to get backed up.' 418 | e95.code = 2147749991 419 | errors[2147749991] = e95 420 | var e96 = new Error('wbemErrNullSecurityDescriptor') 421 | e96.description = 'Windows Server 2003: A null security descriptor was used.' 422 | e96.code = 2147749992 423 | errors[2147749992] = e96 424 | var e97 = new Error('wbemErrTimeout') 425 | e97.description = 'Windows Server 2003: The operation timed out.' 426 | e97.code = 2147749993 427 | errors[2147749993] = e97 428 | var e98 = new Error('wbemErrInvalidAssociation') 429 | e98.description = 'Windows Server 2003: The association being used is not valid.' 430 | e98.code = 2147749994 431 | errors[2147749994] = e98 432 | var e99 = new Error('wbemErrAmbiguousOperation') 433 | e99.description = 'Windows Server 2003: The operation was ambiguous.' 434 | e99.code = 2147749995 435 | errors[2147749995] = e99 436 | var e100 = new Error('wbemErrQuotaViolation') 437 | e100.description = 'Windows Server 2003: WMI is taking up too much memory. This could be caused either by low memory availability or excessive memory consumption by WMI.' 438 | e100.code = 2147749996 439 | errors[2147749996] = e100 440 | var e101 = new Error('wbemErrTransactionConflict') 441 | e101.description = 'Windows Server 2003: The operation resulted in a transaction conflict.' 442 | e101.code = 2147749997 443 | errors[2147749997] = e101 444 | var e102 = new Error('wbemErrForcedRollback') 445 | e102.description = 'Windows Server 2003: The transaction forced a rollback.' 446 | e102.code = 2147749998 447 | errors[2147749998] = e102 448 | var e103 = new Error('wbemErrUnsupportedLocale') 449 | e103.description = 'Windows Server 2003: The locale used in the call is not supported.' 450 | e103.code = 2147749999 451 | errors[2147749999] = e103 452 | var e104 = new Error('wbemErrHandleOutOfDate') 453 | e104.description = 'Windows Server 2003: The object handle is out of date.' 454 | e104.code = 2147750000 455 | errors[2147750000] = e104 456 | var e105 = new Error('wbemErrConnectionFailed') 457 | e105.description = 'Windows Server 2003: Indicates that the connection to the SQL database failed.' 458 | e105.code = 2147750001 459 | errors[2147750001] = e105 460 | var e106 = new Error('wbemErrInvalidHandleRequest') 461 | e106.description = 'Windows Server 2003: The handle request was not valid.' 462 | e106.code = 2147750002 463 | errors[2147750002] = e106 464 | var e107 = new Error('wbemErrPropertyNameTooWide') 465 | e107.description = 'Windows Server 2003: The property name contains more than 255 characters.' 466 | e107.code = 2147750003 467 | errors[2147750003] = e107 468 | var e108 = new Error('wbemErrClassNameTooWide') 469 | e108.description = 'Windows Server 2003: The class name contains more than 255 characters.' 470 | e108.code = 2147750004 471 | errors[2147750004] = e108 472 | var e109 = new Error('wbemErrMethodNameTooWide') 473 | e109.description = 'Windows Server 2003: The method name contains more than 255 characters.' 474 | e109.code = 2147750005 475 | errors[2147750005] = e109 476 | var e110 = new Error('wbemErrQualifierNameTooWide') 477 | e110.description = 'Windows Server 2003: The qualifier name contains more than 255 characters.' 478 | e110.code = 2147750006 479 | errors[2147750006] = e110 480 | var e111 = new Error('wbemErrRerunCommand') 481 | e111.description = 'Windows Server 2003: Indicates that an SQL command should be rerun because there is a deadlock in SQL. This can be returned only when data is being stored in an SQL database.' 482 | e111.code = 2147750007 483 | errors[2147750007] = e111 484 | var e112 = new Error('wbemErrDatabaseVerMismatch') 485 | e112.description = 'Windows Server 2003: The database version does not match the version that the repository driver processes.' 486 | e112.code = 2147750008 487 | errors[2147750008] = e112 488 | var e113 = new Error('wbemErrVetoDelete') 489 | e113.description = 'Windows Server 2003: WMI cannot do the delete operation because the provider does not allow it.' 490 | e113.code = 2147750010 491 | errors[2147750010] = e113 492 | var e114 = new Error('wbemErrVetoPut') 493 | e114.description = 'Windows Server 2003: WMI cannot do the put operation because the provider does not allow it.' 494 | e114.code = 2147750010 495 | errors[2147750010] = e114 496 | var e115 = new Error('wbemErrInvalidLocale') 497 | e115.description = 'Windows Server 2003: The specified locale identifier was not valid for the operation.' 498 | e115.code = 2147750016 499 | errors[2147750016] = e115 500 | var e116 = new Error('wbemErrProviderSuspended') 501 | e116.description = 'Windows Server 2003: The provider is suspended.' 502 | e116.code = 2147750017 503 | errors[2147750017] = e116 504 | var e117 = new Error('wbemErrSynchronizationRequired') 505 | e117.description = 'Windows Server 2003: The object must be committed and retrieved again before the requested operation can succeed. This constant is returned when an object must be committed and re-retrieved to see the property value.' 506 | e117.code = 2147750018 507 | errors[2147750018] = e117 508 | var e118 = new Error('wbemErrNoSchema') 509 | e118.description = 'Windows Server 2003: The operation cannot be completed because no schema is available.' 510 | e118.code = 2147750019 511 | errors[2147750019] = e118 512 | var e119 = new Error('wbemErrProviderAlreadyRegistered') 513 | e119.description = 'Windows Server 2003: The provider registration cannot be done because the provider is already registered.' 514 | e119.code = 2147750020 515 | errors[2147750020] = e119 516 | var e120 = new Error('wbemErrProviderNotRegistered') 517 | e120.description = 'Windows Server 2003: The provider for the requested data is not registered.' 518 | e120.code = 2147750021 519 | errors[2147750021] = e120 520 | var e121 = new Error('wbemErrFatalTransportError') 521 | e121.description = 'Windows Server 2003: A fatal transport error occurred and other transport will not be attempted.' 522 | e121.code = 2147750022 523 | errors[2147750022] = e121 524 | var e122 = new Error('wbemErrEncryptedConnectionRequired') 525 | e122.description = 'Windows Server 2003: The client connection to WINMGMT must be encrypted for this operation. The IWbemServices proxy security settings should be adjusted and the operation retried.' 526 | e122.code = 2147750023 527 | errors[2147750023] = e122 528 | var e123 = new Error('wbemErrRegistrationTooBroad') 529 | e123.description = 'Windows Server 2003: The provider registration overlaps with the system event domain.' 530 | e123.code = 2147753985 531 | errors[2147753985] = e123 532 | var e124 = new Error('wbemErrRegistrationTooPrecise') 533 | e124.description = 'Windows Server 2003: A WITHIN clause was not used in this query.' 534 | e124.code = 2147753986 535 | errors[2147753986] = e124 536 | var e125 = new Error('wbemErrTimedout') 537 | e125.description = 'Windows Server 2003: Automation-specific error.' 538 | e125.code = 2147758081 539 | errors[2147758081] = e125 540 | var e126 = new Error('wbemErrResetToDefault') 541 | e126.description = 'undefined' 542 | e126.code = 2147758082 543 | errors[2147758082] = e126 544 | 545 | // *** end generated errors ***// 546 | 547 | module.exports = errors 548 | 549 | 550 | 551 | 552 | --------------------------------------------------------------------------------