fresc81 / node-winreg

node module that provides access to the Windows Registry through the REG commandline tool
211 stars 60 forks source link

error in proc.on('close', function (code) #50

Closed crb123456 closed 6 years ago

crb123456 commented 6 years ago

when querying for the subkeys of a key in

for (var i = 0, l = lines.length; i < l; i++)

the first line from the reg query contains only "\r" to avoid returning this you apparently "skip" it with the code

   if (line.length > 0) {
      log(line);
      if (lineNumber != 0) {
        items.push(line);
      }
      ++lineNumber;
    }

but for lines with only "\r", trim removes them and so the line.length is 0 and lineNumber is not incremented and so the first line with something other than spaces or \r is skipped.

lines[0].length -> 1 lines[0].trim().length ->0

Have not done it yet but it would seem that just removing the if (lineNumber != 0) and simply pushing the line would work but am not sure it that is the only reason this was placed here.

In any case I am having other issues but found this along the way and easier to report now so perhaps its the other issue which I have not found yet

crb123456 commented 6 years ago

So it continues. When trying to find all the subkeys of a key, reg query key returns an array of lines which just include the key names without values so they do not match the ITEM_PATTERN

eg

‌HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\node_native is returned from reg.exe query HKCU\Software\Mozilla\NativeMessagingHosts\ but is eliminated in the ITEM_PATTERN match.

Perhaps I just do not understand how to use winreg to enumerate the subkeys of a value

crb123456 commented 6 years ago

Ok so I am not so bright. Have to call keys function.

In my defense, is not shown in the readme. GREAT CODE it is really helping me in other areas as I am old at programming but new at node.js. I had to find it browsing the code. I am MUCH better off for having done so as I learned a lot (about how to call an external program) but documentation could be improved.

Thanks