Skip to content

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

Open

Description

@pateljoel

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!

Activity

  1. pateljoel commented on Jun 9, 2021

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

  2. Nokel81 commented on Jul 7, 2021

    @Nokel81

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

  3. semireg commented on Jul 23, 2021

    @semireg

    @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.
    
  4. Nokel81 commented on Jul 23, 2021

    @Nokel81

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

  5. semireg commented on Jul 23, 2021

    @semireg

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

  6. Nokel81 commented on Sep 13, 2021

    @Nokel81

    Will do

  7. Nokel81 commented on Sep 13, 2021

    @Nokel81
  8. semireg commented on Sep 14, 2021

    @semireg

    @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.
    
  9. DanielMichelfelderAtFoerch commented on Apr 10, 2025

    @DanielMichelfelderAtFoerch

    I have troubles with the package node-machine-id, also. The package node-module-id uses REG.exe for windows, which has been blocked by our administrators. It would be nice, when nx.dev wouldn't use this package and find another solution the generate a unique machine id. (https://www.npmjs.com/package/uuid -> store id somewhere?)

    We need a chance to use nx.dev in our company without changing the administrative permissions / group policies.

    Another thought: Give us the possibility to store the machine id as environment file?

    .env

    MACHINE_ID=some_incredible_id
    
  10. DanielMichelfelderAtFoerch commented on Apr 10, 2025

    @DanielMichelfelderAtFoerch

    Just for all the seeking users out there:

    You have the option to use inital cloud functionality or the local one. In case you don't use the advantages of sharing the cache in the cloud, the generation of the machineId is not neccessary.

    I added the following code to my nx.json:

    
      "tasksRunnerOptions": {
        "default": {
          "runner": "nx/tasks-runners/default",
          "options": {
            "cacheableOperations": []
          }
        }
      }
    
    

    ... that let me execute the nx serve - command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions