Windows: install non privileged to AppData

Hi everyone, many modern programs, which are only intended to used as a non privileged user are nowadays already installed to AppData/Local. E.g. Visual Studio Code or Obsidian.

This would allow installing Anki without local admin privileges, which would first of all reduce the impact of a malicious install exe and secondly (and maybe more importantly) allow users to install Anki on machine, where they do not have local admin privilege (e.g. work computers). What do you think of this idea?

1 Like

I’m assuming that the main argument for using c:\Program Files is that the app can be installed once and then used by multiple users, instead of each user having their own copy. That’s probably not too common in practice, so I would be happy to accept a PR that changes the default location. I believe users can already customize the install location, so if they’re being prompted for admin access before doing that or even after doing that, then there may be an another issue going on.

1 Like

Thanks for the input. I think a flow like this should fix this:

start install.exe and you get those radio buttons:

  • install for all users (with UAC prompt): Program Files
  • install just for me: AppData

I will take a look when I find time. How is the flow here? Should I create an issue on GitHub? This was my initial idea anyways, but it said that stuff like this should be discussed here first

1 Like

You can either follow up here or on a GitHub issue. Once you have it in a working state, please post a PR on GitHub.

The installer code is in qt/bundle/win/anki.template.nsi, and can be tested with .\ninja bundle after following all the other steps in docs/development.md, and confirming you can run a source build locally.

Do VS Code & Obsidian offer those options? Perhaps we’d be better off keeping things simple and just changing the default.

Something else that will need addressing is that the install location is written into HKEY_LOCAL_MACHINE, so that it can be reused & the old version removed when upgrading. I’m guessing that is what is prompting UAC access, and it will presumably need to be changed to HKEY_CURRENT_USER instead. But it would be nice if we fall back on the old key for lookup or check the old default location & display a warning, so users don’t accidentally install two different versions on their machine in different locations.

1 Like

I looked into vscode and obsidian installers:

vscode

(0. if already installed, there is a prompt asking the user if they are sure)

  1. Accept eula
  2. choose install location (by default C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code)
  • if you change it to e.g. program files it exits with an access denied message (no auto elevation, user will have to elevate it themself)
  1. install

I think this should be also fine for anki (there is no eula, so this will be skipped). I think we do not need auto elevation to admin either?

obsidian

  1. double click exe and it installs itself to the default location (no user prompt)
  2. open up obsidian

Seems a little bit rushed. I guess we want the user to be able to specify the location.

proposed solution for anki

  1. double click exe as normal user (non elevated)
  2. query if anki is already installed and if installed ask user of they want to continue
  3. choose install location (default: C:\Users\USERNAME\AppData\Local\Programs\Anki)
  4. install

Just wanted to document my findings here. I will look into the registry key and find out how we can go around it.

1 Like

Sounds good :+1:

Apparently I cannot put links in my comments(?). Anyhow, pull request number is: 2497

New users are unable to post links, as it cuts down on the spam the forum gets. Link for reference: Implement non elevated installer by mgrottenthaler · Pull Request #2497 · ankitects/anki · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.