Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bradisbell opened this issue Feb 20, 2019 · 3 comments

Comments

@bradisbell
Copy link

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?

@tahoemate
Copy link

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.

@bradisbell
Copy link
Author

@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.

@phuonghuynh
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants