Run electron app as admin windows

Viewed 2332

I am writing an electron app that I need to run with admin access (like sudo).I haven't created any installer for that app.

I know that I can write sudo electron . in linux to start my app as root but what about windows? Is there any similar command?

2 Answers

If you're using electron builder, you can make the build that will run with admin rights by adding this in your builder config:

win: {
  requestedExecutionLevel: 'requireAdministrator',
}

If you can find the docs here

Note

Keep in mind, if you run an app with admin rights the drag & drop feature will not work

So instead of launching the whole app with admin rights, you should create a separate child process and then run that process with admin rights

Related