Skip to content

Commit

Permalink
(GH-794) Warn when non-admin in default install
Browse files Browse the repository at this point in the history
Right now choco provides a warning when an administrator is using
Chocolatey without elevation, but provides no warning when the user is
a non-administrator and using Chocolatey in the default install
location. Check for that and provide a warning for that as well.
  • Loading branch information
ferventcoder committed Jun 16, 2016
1 parent ca16322 commit 8abfd96
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/chocolatey/infrastructure.app/runners/GenericRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public int count(ChocolateyConfiguration config, Container container, bool isCon

public void warn_when_admin_needs_elevation(ChocolateyConfiguration config)
{
var shouldWarn = (!config.Information.IsProcessElevated && config.Information.IsUserAdministrator);
var shouldWarn = (!config.Information.IsProcessElevated && config.Information.IsUserAdministrator)
|| (!config.Information.IsUserAdministrator && ApplicationParameters.InstallLocation.is_equal_to(ApplicationParameters.CommonAppDataChocolatey));

if (shouldWarn)
{
Expand All @@ -244,7 +245,11 @@ public void warn_when_admin_needs_elevation(ChocolateyConfiguration config)
You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell. When you open the command shell, you should ensure
that you do so with ""Run as Administrator"" selected.
that you do so with ""Run as Administrator"" selected. If you are
attempting to use Chocolatey in a non-administrator setting, you
must select a different location other than the default install
location. See
https://chocolatey.org/install#non-administrative-install for details.
");
var selection = InteractivePrompt.prompt_for_confirmation(@"
Do you want to continue?", new[] { "yes", "no" },
Expand Down

0 comments on commit 8abfd96

Please sign in to comment.