electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.57k stars 1.73k forks source link

Auto Update without Admin and perMachine: true #8354

Open nik736 opened 1 month ago

nik736 commented 1 month ago

Hi there, I would like to allow my users to install my application under Windows with admin rights (UAC). When installing it should write some registry entries to set everything up. I have a custom installer.nsh script like described in the docs that does this. This works. I am auto updating and currently it opens the UAC dialogue every time, since perMachine is set to true.

The problem is, that this application also runs on terminal servers. So the process is basically to install it with admin rights so all (terminal) users have access to it BUT the auto update should be able to run without admin rights.

My idea was to change the install directory to C:\Application instead of the default C:\Program Files\Application. When installing everything can be created for all users, but when updating it only has to change files within the writeable directory so that it wouldn't need admin rights.

My question is simply if this is possible in general or are admin rights needed as soon as perMachine is set to true and this can't be changed?

Any help is appreciated, thanks!

mmaietta commented 1 month ago

Looking at the code, it looks like perMachine: true requires the elevated helper (admin UAC dialogue) https://github.com/electron-userland/electron-builder/blob/fb1666997b50758464280d03eb03fbdd54c0d45d/packages/app-builder-lib/src/targets/nsis/nsisUtil.ts#L104-L108

I don't think it's possible to not have the elevate.exe helper run for autoupdate. The auto-update logic first attempts to install without the elevation, and then has a fallback to "elevate" the installer, unless this logic resolves to true https://github.com/electron-userland/electron-builder/blob/fb1666997b50758464280d03eb03fbdd54c0d45d/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts#L338-L340