kessler / node-regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
MIT License
279 stars 45 forks source link

regedit.putValue():error:unsupported hive #109

Open lister0701 opened 1 year ago

lister0701 commented 1 year ago

My Code: image image

Exception: image

I feel very strange, clearly has been modified successfully image

Brothers, please help me.

gggscript commented 1 year ago

At /lib/helper.js line 14 you need to patch the write function to

function write(m) {
  if (m) {
    var b = module.exports.encode(m)
    debug(b)
    return stream.write(b)
  }
  return false
}
function write(m) {
+  if (m) {
    var b = module.exports.encode(m)
    debug(b)
    return stream.write(b)
+  }
  return false
}
gggscript commented 1 year ago

Or if you want to support falsy values, change the whole function to:

module.exports.writeArrayToStream = function(arr, stream, optionalCallback) {
    function write(m) {
        if (m) {
      var b = module.exports.encode(m)
            debug(b)
            return stream.write(b)
    }
        return false
    }

    while (arr.length) write(arr.pop())

    if (arr.length === 0) {
        stream.write(WIN_EOL, optionalCallback)
        return
    }

    stream.once('drain', function() {
        module.exports.writeArrayToStream(arr, stream, optionalCallback)
    })
}
filmerjarred commented 1 year ago

reverting to 5.0.0 solved it for me :)

kessler commented 1 year ago

@lister0701 please try version 5.1.2 and let me know if it solved your problem.

Dufftwt commented 6 months ago

@kessler Hi man, sorry for bringing this back up so late, but this is still a problem in 5.1.2, I'm using Win 11 and here's my current code, I just want to list apps that start up

const promisifiedRegedit = require('regedit').promisified;

async function main() {
    const listResult = await promisifiedRegedit.list('HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run');
    console.log(listResult);
}

main();
kessler commented 6 months ago

will look into it.

Namicici commented 6 months ago

@kessler Hi man, sorry for bringing this back up so late, but this is still a problem in 5.1.2, I'm using Win 11 and here's my current code, I just want to list apps that start up

const promisifiedRegedit = require('regedit').promisified;

async function main() {
    const listResult = await promisifiedRegedit.list('HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run');
    console.log(listResult);
}

main();

replace 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run' to 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run'