kessler / node-regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
MIT License
281 stars 45 forks source link

Added DeleteValue, Promises and REG_NONE support #67

Closed M1cr0M1nd closed 4 years ago

lhjt commented 5 years ago
lhjt commented 5 years ago

DeleteValue issue

When trying to use DeleteValue with the following values:

{
        "HKLM\\SOFTWARE\\Policies\\Google\\Chrome": {
            "RestoreOnStartup": {
                "value": "4",
                "type": "REG_DWORD"
            }
        },
        "HKLM\\SOFTWARE\\Policies\\Google\\Chrome\\RestoreOnStartupURLs": {
            "1": {
                "value": "https://www.google.com/",
                "type": "REG_SZ"
            }
        }
}

The function fails at helper.js:18: image

Any clue as to what might be causing this? These values work when using the putValue function.

I also tried passing an array as an argument instead of an object, however, it just returns Error: vbscript process reported unknown error code 1.

M1cr0M1nd commented 5 years ago

@LOHT03

Sorry, I'll update the readme in abit, but the usage is as follows: registry.deleteValue(['HKLM\SOFTWARE\Policies\Google\Chrome\RestoreOnStartup', 'HKLM\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs\1'])

lhjt commented 5 years ago

@M1cr0M1nd, unfortunately, I am still unable to get it to work. Error: vbscript process reported unknown error code 1 is still being thrown. image

Here is the function that I am using:

export function delVal(values) {
    return new Promise((resolve, reject) => {
        console.log(values);
        deleteValue(values, err => {
            if (err) {
                reject(err);
            } else {
                resolve();
            }
        });
    });
}

Values (what is being logged), displays: image And I believe that is what is meant to be passed the function (If I read it correctly). The values do exist in the registry.

I also tried using the promisifed version that you included in your package but the result is the same. If it's of any help, the values array, when the callback is being executed, is empty [].

Am I implementing this wrong?

M1cr0M1nd commented 4 years ago

@LOHT03

tried this and it works (the only difference from my example is that i forgot the double '\' for escaping)

const registry = require('./index')

function delVal(values) {
  return new Promise((resolve, reject) => {
      console.log(values);
      registry.deleteValue(values, err => {
          if (err) {
              reject(err);
          } else {
              resolve()
          }
      })
  })
}

async function main () {
  console.log('Start')
  try {
    await delVal(['HKLM\\SOFTWARE\\Policies\\Google\\Chrome\\RestoreOnStartup', 'HKLM\\SOFTWARE\\Policies\\Google\\Chrome\\RestoreOnStartupURLs\\1'])
  } catch(e) {
    console.log('err', e)
  }
  console.log('End')
}

main()
lhjt commented 4 years ago

@M1cr0M1nd, thank you very much, managed to get it to work.

PickRelated commented 3 years ago

@kessler do you mind publishing it to npm? Latest version there is 3.0.3

kessler commented 3 years ago

@PickRelated certainly. We were actually meaning to do this anyway but since we don't have a proper CI setup yet we're doing the testing manually. Expect a release within 7 days.

kessler commented 3 years ago

@PickRelated published @4.0.0 Please let us know if you run into any issues, we've tested this thoroughly but still missed unit tests for the async api so that was manually tested for now

PickRelated commented 3 years ago

@kessler thanks a ton! I will try it out and post if something goes wrong.