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

Command failed: Registry editing has been disabled by your administrator. #56

Open
pateljoel opened this issue May 29, 2021 · 8 comments · May be fixed by #57
Open

Command failed: Registry editing has been disabled by your administrator. #56

pateljoel opened this issue May 29, 2021 · 8 comments · May be fixed by #57

Comments

@pateljoel
Copy link

I am having lots of errors on Windows (App not loading properly) and after some digging, the error happens to be from this library that relies on running regedit in the background.

If I run this code:

const machine = require('node-machine-id');

machine.machineId().then((id) => {
    console.log(id);
}).catch((err) => {
    console.log(err);
})

I get the following error on Windows:

C:\Users\j\machineId> node index.js
Error: Error while obtaining machine id: Error: Command failed: %windir%\System32\REG.exe QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography /v MachineGuid
ERROR: Registry editing has been disabled by your administrator.

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:314:20)
    at Pipe.<anonymous> (net.js:676:12)
    at C:\Users\j\machineId\node_modules\node-machine-id\dist\index.js:1:7964
    at ChildProcess.exithandler (child_process.js:315:5)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:314:20)
    at Pipe.<anonymous> (net.js:676:12)

The error hints that this user does not have admin privileges to run regedit, thus is unable to obtain the unique machine ID. Is there a way of resolving this issue?

Also, thank you for building this library!

@pateljoel
Copy link
Author

Hello, is there an update on this? I thought that this library does not need elevated rights for the Machine IDs (GUID) but found out that this library silently needs elevated access to regedit.

And from the features page:

...And No elevated rights required

But from my tests it needs elevated access so it is a bit misleading here, potential usecase of this failing is getting the Machine IDs of work computers.

Is there a workaround for this?
Thanks.

@Nokel81
Copy link

Nokel81 commented Jul 7, 2021

@pateljoel I have submitted a PR to fix this issue (though it might be a bit big).

@semireg
Copy link

semireg commented Jul 23, 2021

@Nokel81, I am in the process of testing your patch on Windows, but heads up that your work breaks builds on macOS. Here's what I'm seeing:

An unhandled error occurred inside electron-rebuild
internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module 'node-addon-api'
Require stack:

and... if I try to satisfy that dependency:

Error:   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
warning: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
  CXX(target) Release/obj.target/reg/reg.o
In file included from ../reg.cc:1:
/Users/caylan/local-dev/label-live/app/LabelLIVE-App/app/node_modules/node-addon-api/napi.h:32:6: error: Exception support not detected.       Define either NAPI_CPP_EXCEPTIONS or NAPI_DISABLE_CPP_EXCEPTIONS.
    #error Exception support not detected. \
     ^
../reg.cc:4:10: fatal error: 'windows.h' file not found
#include <windows.h>
         ^~~~~~~~~~~
2 errors generated.

@Nokel81
Copy link

Nokel81 commented Jul 23, 2021

Ah I am sorry about that, maybe a dynamic import for only windows would be better?

@semireg
Copy link

semireg commented Jul 23, 2021

@Nokel81, I had a windows user test my app's build with your PR and it worked. So that's good news!

I'm not in a good position to modify this codebase, but if you want to take a stab at a solution (dynamic import) I'm happy to test it across macOS and Windows.

@Nokel81
Copy link

Nokel81 commented Sep 13, 2021

Will do

@Nokel81
Copy link

Nokel81 commented Sep 13, 2021

@semireg done

@semireg
Copy link

semireg commented Sep 14, 2021

@Nokel81, did you see the latest comment over at native-reg? He's modified the gypfile to minimize complexity with bundling/packaging.

simonbuchan/native-reg#23 (comment)

Give this a try in @next tag / 0.3.6 - if it's all good i'll release it to latest.

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

Successfully merging a pull request may close this issue.

3 participants