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

Can not work with pkg. #70

Closed kkqy closed 3 years ago

kkqy commented 5 years ago

If I use pkg(https://github.com/zeit/pkg) to pack my project, this module can't work,and it shows:

Error: vbscript process reported unknown error code 1
    at ChildProcess.<anonymous> (E:\snapshot\client_installer\node_modules\regedit\index.js:298:20)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:187:15)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
Error: vbscript process reported unknown error code 1
    at ChildProcess.<anonymous> (E:\snapshot\client_installer\node_modules\regedit\index.js:298:20)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:187:15)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

Is there any way to fix it?

lhjt commented 4 years ago

Have you tried setting an external VBS location in the package? Refer to #60 for more information (It's for ASAR but it may work for your app as well, take a look and see if it works). The readme also has information on how to use that.

iSued commented 2 years ago

I've done this way and i just need to have my package and vbs at the same level. Obviously you can decide to change level.

    let regedit = require('regedit')
    const pathNode = require('path');
    const appDir = pathNode.resolve()
    await regedit.setExternalVBSLocation(appDir + '/vbs');
    regedit = require('regedit').promisified
juxnpxblo commented 1 month ago

if you are using electron-forge you should set your config like this

const config: ForgeConfig = {
  packagerConfig: {
    extraResource: ["node_modules/regedit/vbs"],
  },
};

then the scripts will go to (on Windows)

C:\Users\$USER\AppData\Local\electron-app\app-1.0.0\resources\vbs

so you can just

const vbsDir = path.join(process.resourcesPath, "vbs");
setExternalVBSLocation(vbsDir);