From 3768be1b217c19354591438464a4d2bcfb6508ff Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 7 Nov 2019 11:54:22 -0800 Subject: [PATCH] Remove the not-working 'run `Update-Help` from `Get-Help` when `Get-Help` runs for the first time' feature (#10974) --- .../engine/PSConfiguration.cs | 21 --------- .../help/HelpCommands.cs | 22 --------- .../help/UpdatableHelpSystem.cs | 46 ------------------- .../help/UpdateHelpCommand.cs | 3 -- .../resources/HelpDisplayStrings.resx | 6 --- 5 files changed, 98 deletions(-) diff --git a/src/System.Management.Automation/engine/PSConfiguration.cs b/src/System.Management.Automation/engine/PSConfiguration.cs index 01d12ae758..f158a71076 100644 --- a/src/System.Management.Automation/engine/PSConfiguration.cs +++ b/src/System.Management.Automation/engine/PSConfiguration.cs @@ -178,27 +178,6 @@ namespace System.Management.Automation.Configuration : string.Concat(shellId, ":", "ExecutionPolicy"); } - /// - /// Existing Key = HKLM\SOFTWARE\Microsoft\PowerShell - /// Proposed value = Existing default. Probably "0" - /// - /// Schema: - /// { - /// "DisablePromptToUpdateHelp" : bool - /// } - /// - /// Boolean indicating whether Update-Help should prompt. If the value cannot be read, it defaults to false. - internal bool GetDisablePromptToUpdateHelp() - { - return ReadValueFromFile(ConfigScope.AllUsers, "DisablePromptToUpdateHelp"); - } - - internal void SetDisablePromptToUpdateHelp(bool prompt) - { - WriteValueToFile(ConfigScope.AllUsers, "DisablePromptToUpdateHelp", prompt); - } - - /// /// Get the names of experimental features enabled in the config file. /// internal string[] GetExperimentalFeatures() diff --git a/src/System.Management.Automation/help/HelpCommands.cs b/src/System.Management.Automation/help/HelpCommands.cs index c666cae640..b5a966a340 100644 --- a/src/System.Management.Automation/help/HelpCommands.cs +++ b/src/System.Management.Automation/help/HelpCommands.cs @@ -246,19 +246,6 @@ namespace Microsoft.PowerShell.Commands protected override void BeginProcessing() { _timer.Start(); - - if (!Online.IsPresent && UpdatableHelpSystem.ShouldPromptToUpdateHelp() && HostUtilities.IsProcessInteractive(MyInvocation) && HasInternetConnection()) - { - if (ShouldContinue(HelpDisplayStrings.UpdateHelpPromptBody, HelpDisplayStrings.UpdateHelpPromptTitle)) - { - System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace).AddCommand("Update-Help").Invoke(); -#if LEGACYTELEMETRY - _updatedHelp = true; -#endif - } - - UpdatableHelpSystem.SetDisablePromptToUpdateHelp(); - } } /// @@ -716,15 +703,6 @@ namespace Microsoft.PowerShell.Commands WriteProgress(record); } - /// - /// Checks if we can connect to the internet. - /// - /// - private bool HasInternetConnection() - { - return true; // TODO:CORECLR wininet.dll is not present on NanoServer - } - #region Helper methods for verification of parameters against NoLanguage mode internal static void VerifyParameterForbiddenInRemoteRunspace(Cmdlet cmdlet, string parameterName) diff --git a/src/System.Management.Automation/help/UpdatableHelpSystem.cs b/src/System.Management.Automation/help/UpdatableHelpSystem.cs index 68a3146424..eba8c8583d 100644 --- a/src/System.Management.Automation/help/UpdatableHelpSystem.cs +++ b/src/System.Management.Automation/help/UpdatableHelpSystem.cs @@ -1500,52 +1500,6 @@ namespace System.Management.Automation.Help return string.IsNullOrEmpty(defaultSourcePath) ? null : defaultSourcePath; } - /// - /// Sets the DisablePromptToUpdatableHelp regkey. - /// - internal static void SetDisablePromptToUpdateHelp() - { - try - { - PowerShellConfig.Instance.SetDisablePromptToUpdateHelp(true); - } - catch (UnauthorizedAccessException) - { - // Ignore AccessDenied related exceptions - } - catch (SecurityException) - { - // Ignore AccessDenied related exceptions - } - } - - /// - /// Checks if it is necessary to prompt to update help. - /// - /// - internal static bool ShouldPromptToUpdateHelp() - { -#if UNIX - // TODO: This workaround needs to be removed once updatable help - // works on Linux. - return false; -#else - try - { - if (!Utils.IsAdministrator()) - { - return false; - } - - return PowerShellConfig.Instance.GetDisablePromptToUpdateHelp(); - } - catch (SecurityException) - { - return false; - } -#endif - } - #endregion #region Events diff --git a/src/System.Management.Automation/help/UpdateHelpCommand.cs b/src/System.Management.Automation/help/UpdateHelpCommand.cs index e670ea3d6a..c58877cfaf 100644 --- a/src/System.Management.Automation/help/UpdateHelpCommand.cs +++ b/src/System.Management.Automation/help/UpdateHelpCommand.cs @@ -143,9 +143,6 @@ namespace Microsoft.PowerShell.Commands /// protected override void BeginProcessing() { - // Disable Get-Help prompt - UpdatableHelpSystem.SetDisablePromptToUpdateHelp(); - if (_path == null) { // Pull default source path from GP diff --git a/src/System.Management.Automation/resources/HelpDisplayStrings.resx b/src/System.Management.Automation/resources/HelpDisplayStrings.resx index 638f7fc968..ed4ed92034 100644 --- a/src/System.Management.Automation/resources/HelpDisplayStrings.resx +++ b/src/System.Management.Automation/resources/HelpDisplayStrings.resx @@ -449,12 +449,6 @@ To update help again, add the Force parameter to your command. The root level element of the help content must be "helpItems". - - The Update-Help cmdlet downloads the most current Help files for PowerShell modules, and installs them on your computer. For more information about the Update-Help cmdlet, see https://go.microsoft.com/fwlink/?LinkId=210614. - - - Do you want to run Update-Help? - Saving Help for module {0}