From 8abfd962ee1d10bbeb648c20ce95920398d81c04 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 16 Jun 2016 09:21:35 -0500 Subject: [PATCH] (GH-794) Warn when non-admin in default install 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. --- .../infrastructure.app/runners/GenericRunner.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs index c7bd2c0321..c464a56544 100644 --- a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs +++ b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs @@ -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) { @@ -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" },