Chocolatey as non-admin user

I've discovered how to do it for both administrative and non-administrative users. In the Chocolatey non-administrative section of the docs, it says that to install Chocolatey as non-admin, first we have to define a ChocolateyInstall environment variable pointing to a location where Chocolatey should be installed and all users have access (I've used C:\Users\Public\Chocolatey folder). That variable can be set at machine or user level. If we define it at machine level, the same Chocolatey installation can be used for both admin and non-admin packages installs. After setting the variable, we should procede to Chocolatey install, which can be done either as admin or non-admin user.

Then, to install any package there are two ways to do it: if it that requires admin access, we can open a an admin PowerShell (or command prompt) and call choco install <package> with it. Then the app will be installed as the admin user (PETER in my question). If it doesn't require admin access, then we can open a non-admin PowerShell (or command prompt) and call choco install <package> with it. The app gets installed to the current user (JOE in my question).

I've not tested it, but I believe that another option is to set a machine level ChocolateyInstall variable pointing to one location and a user level ChocolateyInstall variable pointing to another location. Then if we install Chocolatey as admin, we would get a "master" Chocolatey install, that can be used to install the majority of the packages (which require admin access according to the documentation). If we install it again as the common user, we would get a "user" Chocolatey install, that can be used to install some specific packages (as Wunderlist). That way, that package can get installed to any number of users, without interfering with the "admin" Chocolatey install.

The drawback is that having 2 Chocolatey installs, the packages will have to be managed at both admin and user level, so upgrades will have to be done at both "master" and "user" level.

In my case, as I have only one user per machine and my users don't install any apps, I've chosen the first option.

Hope it helps someone looking for this.


Thank you Loenardo Puglia for your answer. Really helped me today. My example was Slack installs in $USERPROFILE%/AppData so I experienced this problem. I am, too, needing admin and non-admin use of Chocolatey.

If you've already installed chocolatey as admin (as I did), you can move it and turn it into non-admin, even under Active Directory. Then you can keep all your libraries. At least I did on 02/23/2017. This was the Open Source version of Chocolatey.

By default Chocolatey installs into C:\ProgramData\Chocolatey

And sets a system environment variable ChocolateyInstall = C:\ProgramData\Chocolatey. (Setting this before installing Cocolatey will cause it to install in that dir. Too late for me; I've already installed it.)

And adds C:\ProgramData\Chocolatey\bin to the PATH.

From an admin account you can move that Chocolatey folder to an unprotected area. I chose C:\Chocolatey but any path that you can make accessible to non-admin users should work.

Then I set the permissions on the folder C:\Chocolatey to Users having Full control.

Then re-set the 2 environment variables [reference].

setx ChocolateyInstall "C:\Chocolatey" /m

/m makes it a system wide env var, rather than user.

And for the path, for this minor in-place edit, I prefer to edit the registry rather than play with double quotes on the command line.

regedit.exe

Navigated to HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Modify path and edit the Chocolatey entry as needed and hit OK.

Sometimes you have to re-log in to see the new values of the env vars. [discussion in comments on question]