2

I am trying to install dynamically windows services from my electron app.
For that i am using the node module "node-windows".

This looks like this:

service = new Service({
    name: 'Watcher',
    description: 'Watcher',
    script: 'Watcher.js',
    env: {
        name: "SettingsPath",
        value: storage.getDataPath()
    }
});

service.on('install',function(){
    service.start();
});

service.install();

this works very well on my dev machine.
The app requests for permission to create the service and installs it smoothly.

My Problem
If i compile the app to an exe the app doesnt request me for permissions and print an error

Permission Denied. Requires administrative privileges.

The app creates the service exe successfully at that time and doesnt do anything more.

Ok, so i started the app with admin privileges for testing this behavior.
Nice, the app doesnt show any error, creates the service exe AND ahhhhhh installed the service NOT.

Questions
Why does the app no ​​longer ask for permissions when it is compiled?
Why isn't the service installed when the app is compiled?

If you need any additional information, write me a comment. And thanks for your time.

Tobias
  • 1,534
  • 11
  • 25
  • Did you resolve this issue? I got stuck with the same bottleneck now – Padmapriya Vishnuvardhan Jun 03 '20 at 07:39
  • the path to the elevate.cmd in node-windows is incorrect for electron apps...you can read it here: https://github.com/coreybutler/node-windows/issues/245 – Tobias Jun 03 '20 at 09:21
  • 1
    but you will stuck on more problems....services cant use scripts from asar file, so u must disable or exclude this files...the execute path in the service config would be wrong so you must edit this file after creating...if on the target system of your software is no node.js installed, you need an other executable....maybe another thing i dont remember jet.... – Tobias Jun 03 '20 at 09:25
  • So I am packaging without asar :(. No other options. – Padmapriya Vishnuvardhan Jun 04 '20 at 08:17

1 Answers1

0

the path to the elevate.cmd in node-windows is incorrect for electron apps.
i have documented the way of trouble here

found some more problems to use the node-windows package:

  • cant use scripts from electron asar file (exclude files or diable asar)
  • the executable path from the generated service config is wrong (its the packaged app executable, but must be node.exe or an equivalent executable)
  • service will only run on target system if node.js is installed, or you provide an equivalent
Tobias
  • 1,534
  • 11
  • 25