AceCentre / EyeCommander

An open source computer vision interface that tracks eye movements for individuals with severely-limited mobility.
https://docs.acecentre.org.uk/eyecommander
MIT License
53 stars 4 forks source link

Force running as administrator #35

Closed gavinhenderson closed 2 years ago

gavinhenderson commented 2 years ago

Currently on windows you have to run this application as administrator. This is a limitation cause by other software (such as Grid3) running with elevated privileges so to interact with them we must run as administrator.

You can use the request-execution-level in electron-packager to force the installer to open as Admin.

However, this has a limitation in that when you run the installer it then installs the application to the administrator account and therefore won't create a desktop icon if you are not the administrator.

Ideally we should install it not as admin and then elevate to admin when we run the application. Could be hard though

willwade commented 2 years ago

maybe a Solution is to install in Program Files.. https://www.authentise.com/post/electron-and-uac-on-windows

gavinhenderson commented 2 years ago

Thats a really useful blog post and which led to discovering the request-execution-level in electron packager. The flag in electron packager creates a manifest in the same way they have in this blog post.

However, the main problem with their approach is they go for a global install on the machine rather than a per user install. The reason you have to do this is because when you elevate to admin there is no way to know which user to install to because the application thinks the user is the admin, so you can't install it to the current user because you dont know if thats correct, so you have to do a machine wide install. A machine wide install would be fine for EyeCommander, it is unlikely that we will have multiple distinct EyeCommander users on one machine.

But the main problem is our installer doesn't support machine wide installs :( We might be able to hack it so that it does support machine wide installers, but that would be fragile and we would effectively end up building our own installer.

We can switch installer. Electron forge has one other windows installer plugin. https://www.electronforge.io/config/makers/wix-msi This might work for us, worth a try. We can try other installers but we would have to stop using electron-forge but I really don't want to do that because it does ALL the hard work when it comes to application packaging.

Its a messy problem :( If anyone picks this up let me know and I can talk you through everything I tried and why I gave up in the end.

I see three solutions:

willwade commented 2 years ago

How about running a script post install that changes the run as admin setting? Either altering it via the shortcut or a registry entry.

See method 3 & 4 at https://www.top-password.com/blog/make-your-program-always-run-as-administrator/

So we'd have to create a poweshell / bat file and add that to the repo and for a post install kind of hook

And this might be useful https://stackoverflow.com/questions/52724004/configure-electron-builder-to-run-powershell-script

gavinhenderson commented 2 years ago

Thats a good shout actually. Squirrel installer exposes the hooks you mentioned so it would be pretty straight forward to run method 3 after install! Glad we have a way forward cause i bashed my head against this for quite a while