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

Access denied in Windows Electron #64

Open
sr258 opened this issue Apr 29, 2022 · 5 comments
Open

Access denied in Windows Electron #64

sr258 opened this issue Apr 29, 2022 · 5 comments

Comments

@sr258
Copy link

sr258 commented Apr 29, 2022

I use node-machine-id in an Electron app that is packages with ASAR.

I see users who can't get the machine ID in their app. My error log includes this message:

Error: Error while obtaining machine id: Error: Command failed: %windir%\System32\REG.exe QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography /v MachineGuid
Zugriff verweigert (= German for 'access denied')

    at ChildProcess.exithandler (node:child_process:406:12)
    at ChildPr...

I thought that the library doesn't use elevated rights. Is this specific to Electron? How can I work around this?

@jrohlandt
Copy link

Hey what happened? Did you find a solution?

@sr258
Copy link
Author

sr258 commented Jan 25, 2023

No, I moved away from the library and generate a random id that I save in the user directory.

@jrohlandt
Copy link

I ended up doing something similar. Thanks for the reply.

@ielektronick
Copy link

ielektronick commented Jan 27, 2023

We received the same error for one of our clients. They have laptops with policies that don't allow editing registry values:

Command failed: %windir%\System32\REG.exe QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography /v MachineGuid\nERROR: Registry editing has been disabled by your administrator.

So, we ended up with something like:

import { v4 as uuidv4 } from 'uuid';
import { machineId } from 'node-machine-id';

let machineUniqueId: string;
try {
  machineUniqueId = await machineId(true);
} catch (error) {
  machineUniqueId = uuidv4();
}

// save id later

@Alucard17
Copy link

hii, I have created custom package which doesn't require admin privileges on windows, https://www.npmjs.com/package/node-machine-uid.

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

4 participants