[Enhancement] Support an "Auto" scope, in addition to "Machine" and "User"
jberezanski opened this issue · 0 comments
Helpers such as Install-ChocolateyEnvironmentVariable
are able to perform their work in per-user or per-machine (all users) scope. The latter is generally preferred (so that the installed package is correctly registered for all users), but requires administrative privileges.
If a package wants to support both per-machine (when running with administrative privileges) and per-user installations, it currently needs to explicitly handle both cases in code, e.g.:
if (Test-ProcessAdminRights) {
Install-ChocolateyPath -pathType Machine ...
} else {
Install-ChocolateyPath -pathType User ...
}
If a package does not specify the scope, User is assumed, which is inconvenient now that per-machine, administrative installation is the secure and recommended approach.
Let's add an "Auto" scope parameter value, which would be interpreted as Machine if user has administrative privileges and as User otherwise. This should also be the default scope, so that the amount of code required in typical packages is minimized.