-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fails if registry editing tools are disabled on windows #27
Comments
I'm seeing this issue too... |
Also seeing this issue as well, would it be possible to implement a fallback to the native tool or another nodejs way of accessing the registry if the REG QUERY command is detected as failed? |
@eohland @joneian @SirNeural Any luck with this issue ? |
@automation-stack You got any chance to look into this issue ? |
No @SweetEvil, I still use my cpp workaround like that: function getMachineIdSync() {
if (process.platform === 'win32') {
let guid = execSync('get-machine-guid.exe').toString()
guid = guid.replace(/\r+|\n+|\s+/ig, '').toLowerCase()
return createHash('sha256').update(guid).digest('hex')
}
else {
return machineIdSync()
} A proper fix could be to implement it as a native module. |
@eohland What is this |
I created my own, It is the compiled version of |
@eohland Does it return same machine Id in each case with |
@SweetEvil Yes, the only difference is the way to retrieve the MachineGuid registry key |
@eohland It didn't compile for me, I am getting some errors. |
@SweetEvil I just tried again and it compile without errors using the VS2015 Developer Command Prompt like this: cl get-machine-guid.c Here is the compiled executable : get-machine-guid.exe.zip |
@eohland Your executable just flickers and returns nothing. I am getting |
@eohland Nevermind, I got it working, just that I am having issues with returning |
Does this occur only is GP specifically "prevent access to registry editing tools" or is it if the user is not a local admin? |
Late to the party but you can also use PowerShell: const {spawnSync} = require('child_process');
const {createHash} = require('crypto');
const getSync = (original = false) => {
const psProc = 'powershell.exe';
const psArgs = ['-NoLogo', '-Command', '-NonInteractive', '(New-Object -ComObject WScript.Shell).RegRead("HKLM\\SOFTWARE\\Microsoft\\Cryptography\\MachineGuid")'];
const output = spawnSync(`${psProc}`, psArgs);
const string = output.stdout.toString().split('\r\n')[0];
return original ? string : hash(string);
};
function hash(guid) {
return createHash('sha256').update(guid).digest('hex');
}
module.exports = {
getSync,
}; |
@DeverStyle '-NonInteractive' should be before '-Command' |
Hi,
If you are on a restricted environment where local group policy prevent access to registry editing tools, the "REG QUERY" command fails.
A workaround for me was to write a native tool (attached below), it work either on native and mixed environment.
get-machine-guid.c.zip
The text was updated successfully, but these errors were encountered: