windows-registry-node icon indicating copy to clipboard operation
windows-registry-node copied to clipboard

Failed to open key error: undefined, even when running as Administrator

Open bradisbell opened this issue 6 years ago • 3 comments
trafficstars

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?

bradisbell avatar Feb 20 '19 19:02 bradisbell

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 avatar Apr 19 '19 19:04 tahoemate

@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 avatar Apr 19 '19 19:04 bradisbell

@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 }`);

phuonghuynh avatar Jul 17 '19 05:07 phuonghuynh