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
279 stars 45 forks source link

Issue while using from .asar package #60

Closed jrsarath closed 4 years ago

jrsarath commented 5 years ago

Hi there, im developing a Electron app, and facing this issue : Condition : packaged app with asar - error thrown = Input Error: Can not find script file APPD_DIR\resources\app.asar\node_modules\regedit\vbs\regList.wsf

APP_DIR represents current project folder

XinYueStudio commented 5 years ago

package.json package:win add --ignore=node_modules/regedit/vbs --extraResource=node_modules/regedit

script add function like this:

let regedit = require('regedit') regedit.setExternalVBSLocation('resources/regedit/vbs');

jeremysu0131 commented 5 years ago

First, set the following code in package.json in build

    "extraResources": [
      {
        "from": "node_modules/regedit/vbs",
        "to": "regedit/vbs",
        "filter": [
          "**/*"
        ]
      }
    ]

Second, set the following code where you use regedit

let regedit = require('regedit');
regedit.setExternalVBSLocation('resources/regedit/vbs');
mohsenmahoski commented 4 years ago

First, set the following code in package.json in build

    "extraResources": [
      {
        "from": "node_modules/regedit/vbs",
        "to": "regedit/vbs",
        "filter": [
          "**/*"
        ]
      }
    ]

Second, set the following code where you use regedit

let regedit = require('regedit');
regedit.setExternalVBSLocation('resources/regedit/vbs');

you saved my life!! thank u!

ghost commented 4 years ago

I still cant figure this out. I created a entry in package.json for extraResources

"name":...
"author":...
"scripts":...
"build": {
    "extraResources": [
      {
        "from": "node_modules/regedit/vbs",
        "to": "src/regedit/vbs",
        "filter": [
          "**/*"
        ]
      }
    ]
  },

Then i added regedit.setExternalVBSLocation('src/regedit/vbs'); in my code.

With these or without I get the same error: Input Error: Can not find script file "C:\.....\dist_electron\vbs\regList.wsf".

What am I doing wrong?

jeremysu0131 commented 4 years ago

I still cant figure this out. I created a entry in package.json for extraResources

"name":...
"author":...
"scripts":...
"build": {
    "extraResources": [
      {
        "from": "node_modules/regedit/vbs",
        "to": "src/regedit/vbs",
        "filter": [
          "**/*"
        ]
      }
    ]
  },

Then i added regedit.setExternalVBSLocation('src/regedit/vbs'); in my code.

With these or without I get the same error: Input Error: Can not find script file "C:\.....\dist_electron\vbs\regList.wsf".

What am I doing wrong?

Looks like your file URL was wrong. It should be: ${builded file location}\win-unpacked\resources\regedit\vbs\regList.wsf

By the way, I used election-builder to build my project

rendomnet commented 3 years ago

@jeremysu0131 Input Error: Can not find script file "C:\Users***\src\vbs\regList.wsf". same error what is url?

rendomnet commented 3 years ago

@jeremysu0131 setExternalVBSLocationis not working for me. It always searching in src\vbs\

A-ANing commented 1 year ago

First, set the following code in package.json in build

    "extraResources": [
      {
        "from": "node_modules/regedit/vbs",
        "to": "regedit/vbs",
        "filter": [
          "**/*"
        ]
      }
    ]

Second, set the following code where you use regedit

let regedit = require('regedit');
regedit.setExternalVBSLocation('resources/regedit/vbs');

If the application is manually started, it can solve the problem; If it starts automatically upon startup, the same error will be reported;

After I set the enable self start option, this method failed and still reported the same error;

Boot self start code:

app.setLoginItemSettings({
            openAtLogin: true,
            openAsHidden: false
        });

Is there someone kind-hearted to help me

davec-fvr commented 10 months ago

For me, I had to add this to the end of electron-builder/config.js rather than in package.json

  extraResources: [
    {
      from: 'node_modules/regedit/vbs',
      to: 'regedit/vbs',
      filter: ['**/*'],
    },
    {
      from: './assets',
      to: './assets',
      filter: ['**/*'],
    },
  ],

and then this as @jeremysu0131 said

let regedit = require('regedit');
regedit.setExternalVBSLocation('resources/regedit/vbs');