-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Service is not installing after compiling #245
Comments
I'm not clear what you mean when referring to the service being installed when the "app is compiled". When Electron is compiled? The most likely reason for seeing differing behavior is a service conflict. If an attempt is made to install a service when it already exists, it merely exits... it does not overwrite an installation. It could also be that Electron needs to request elevated permissions, instead of node-windows. In other words, the user account which is executing the process needs to be "conditioned" before node-windows can do its job. If all of that fails, you should be able to run node-windows in a detached child process. Electron may still run that child process under the same user context, but it may not suppress the prompts. |
example 1: example 2:
example 3:
have you an example? Edit: |
the created service.exe in the daemon folder can be successfully installed via cmd with path/to/daemon/service.exe install if i run this from the electron developers tool in the installed electron app i can install the service as administrator: |
See https://nodejs.org/dist/latest-v12.x/docs/api/child_process.html#child_process_options_detached for detached processes. If it works from the electron devtools, then it's working within the rendering process (as opposed to the main process). It sounds like the user context/permissions are being manipulated within Electron's main process (I just don't know what those manipulations are). You may want to wrap the installation process in a try/catch, writing any errors to a log file. I'd also suggest testing the file system permissions (i.e. fs.accessSync) to make sure the process can write to the appropriate directory from the main process and execute the service.exe file. |
i tested it with a try/catch, this prints no error. The install event also runs through without errors. after some more debugging i found an error in child_process.js. in the first path there is a "app.asar" electron package file, maybe the command line cant open files in this package. The same folder with a other name is unpacked in the same folder. do you now where the first path is defined? |
got this done but the service is not launching the service script... if i changed this to "node_modules/electron/dist/electron.exe" executable from the unpacked app it runs. But in the packaged app this file is not present and with the new generated executable it is not running. So i think we cant get the node context from the packaged app executable. If we change the executable in the xml config to the global node executable, the service runs. Some possible solutions:
*notice: why i am writing this here and not in blog? :-) maybe someone need this |
Thanks for detailing your journey. I'm sure others will find this useful. If you're OK with it, I'll link to this issue from the wiki. In my personal experience with Electron, I wound up writing my own installer to distribute specific files outside of the asar file (and modify them at install time if necessary). It is possible to execute Electron as though it were "just node", and you can find the path using OS tools like "where" (Win32) and "which" (macOS). |
Since I wanted a software that also runs on operating systems that do not have node installed and it does not work via the finished electron app executable, I have included the pure electron binary file in the directory. I can run the services via this like it is a "just note" application. and yes, i edit the xml config file after creating the services programmatically (changed the executable path to the path of the electron binary). if you want you can link this of course to the wiki. |
@coreybutler @Tobias-Keller |
I haven't found a better way. If you find a better way, I would be happy if you share it here. |
Hello Tobias-Keller,Hope you are doing well. |
It's because you have not disabled asar. Electron will package your app files as asar file and Node cant use the files inside the asar file. So disable asar and use the correct path |
Thanks for your quick reply. I managed to start service with below code- service = new Service({ But you can see i am passing path of node.js. So could you help me that how can i run this service where node,js is not installed. |
@Tobias-Keller i can't start service in the electron , but i can start node example, can you show me your code , it bothers me |
@coreybutler how are the scripts run, i dont see any use in the source code |
I'd like to add that you can use a subprocess in your electron app to run a node script that starts the service with node-windows. As long as you can package NodeJS into your app. |
Hi!
I have written a Electron.js app where i want to generate dynamically windows services.
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.
Why does the app no longer ask for permissions when it is compiled?
Why isn't the service installed when the app is compiled?
(Tested the exe on my dev machine, so vue is installed)
The text was updated successfully, but these errors were encountered: