From 43d6581660b9e3e49bfb9cbec5b2eeeb5a8f5bcf Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 13 Sep 2016 17:33:46 -0500 Subject: [PATCH] (GH-893) Fix: Help Warns Required Elevated Rights When running help menus, it should not warn about the need for elevated rights. --- .../infrastructure.app/runners/GenericRunner.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs index 927a951172..283abd919d 100644 --- a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs +++ b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs @@ -58,14 +58,14 @@ private ICommand find_command(ChocolateyConfiguration config, Container containe } else { - if (command.may_require_admin_access()) + if (parseArgs != null) { - warn_when_admin_needs_elevation(config); + parseArgs.Invoke(command); } - if (parseArgs != null) + if (command.may_require_admin_access()) { - parseArgs.Invoke(command); + warn_when_admin_needs_elevation(config); } set_source_type(config); @@ -231,6 +231,8 @@ public int count(ChocolateyConfiguration config, Container container, bool isCon public void warn_when_admin_needs_elevation(ChocolateyConfiguration config) { + if (config.HelpRequested) return; + var shouldWarn = (!config.Information.IsProcessElevated && config.Information.IsUserAdministrator) || (!config.Information.IsUserAdministrator && ApplicationParameters.InstallLocation.is_equal_to(ApplicationParameters.CommonAppDataChocolatey));