3

I created an electron app which can only be started as admin, because it needs it for various command executions. Now it prompts that it must be started as admin. This question was very helpful.

Now I want to start it with admin privileges right away so windows asks for the acception. It shouldn't be able to start the app without admin privileges.

I tried adding --win32metadata.requested-execution-level=requireAdministrator, but then it writes an error on startup (always):

The application has failed to start because the side by side configuration is incorrect.

How can I achive this with the electron packager?

Gehtnet
  • 443
  • 10
  • 25

1 Answers1

3

Your electron-packager code looks fine, and the switch works for me.

This can happen if you are missing Visual C++ Runtimes, or if they're corrupted. Try installing them from here and try again.

If that doesn't help, then you should dig into the Event Viewer, which should come installed on your machine, and see what the specific error is. This page has some additional tips on troubleshooting this issue.

pushkin
  • 9,575
  • 15
  • 51
  • 95
  • I'm getting this error in event viewer, which is not covered on the linked site. `Activation context generation failed for "-REDACTED-PATH-".Error in manifest or policy file "-REDACTED-PATH-" on line 0. Invalid Xml syntax.` – GrumpyCrouton Mar 18 '19 at 13:48
  • @GrumpyCrouton Good to know. I think this is consistent with the hypothesis that something is corrupted or not installed correctly. – pushkin Mar 18 '19 at 14:11
  • @GrumpyCrouton Do you see the error after trying my suggestion, or just before? – pushkin Mar 18 '19 at 14:11
  • This is after. On the site you linked, in step 2, it has a 3rd party installer which I used. I got the same error before and after installing that. – GrumpyCrouton Mar 18 '19 at 14:41
  • @GrumpyCrouton Have you tried with the non-third party installer? Also, can you look at that file (Redacted Path), and see what it looks like? Is that file a Windows thing, or something else? Can you feasibly reinstall/repair the install of the application that the broken file relates to? – pushkin Mar 18 '19 at 14:47
  • That path leads to the .exe file that electron-packager creates that runs the application, i've tried rebuilding the application multiple times. When I run this file, I get the error message which is in the original question in a pop up. This works perfectly fine without the `--win32metadata.requested-execution-level=requireAdministrator` flag – GrumpyCrouton Mar 18 '19 at 14:51
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/190254/discussion-between-grumpycrouton-and-pushkin). – GrumpyCrouton Mar 18 '19 at 14:53