windows-registry-node
windows-registry-node copied to clipboard
Failed to open key error: undefined, even when running as Administrator
This code throws an error:
const registry = require('windows-registry');
const windef = registry.windef;
const key = new registry.Key(windef.HKEY.HKEY_LOCAL_MACHINE, 'SOFTWARE\\SomeVendor\\SomeApp\\Settings');
Failed to open key error: undefined
This happens even when running in an Administrator command prompt. What could the issue be?
Brad would be interested in hearing if you found a solution. I followed a rabbit hole of downgrading node to v8 in an attempt to find a version that played nice with node-ffi and ref. Since I only need a small registry change, will probably develop an EXE to bundle in my electron windows install.
@tahoemate Yeah, I ended up switching to this package: https://github.com/ironSource/node-regedit It's not as efficient, but works well enough.
Unfortunately, it seems that windows-registry-node has been abandoned. It hasn't had meaningful commits in years.
@bradisbell @tahoemate i just used this lib recently, here is my working script, hope this help
const key = new Key(windef.HKEY.HKEY_LOCAL_MACHINE, '', windef.KEY_ACCESS.KEY_READ);
const key2 = key.openSubKey(`SOFTWARE\\SomeVendor\\SomeApp\\Settings`, windef.KEY_ACCESS.KEY_READ);
const value = key2.getValue(`SOMENAME`);
key2.close();
key.close();
console.log(`value=${value }`);