Skip to content

Belphemur/issue1786#1787

Merged
Belphemur merged 9 commits intodevfrom
Belphemur/issue1786
May 23, 2025
Merged

Belphemur/issue1786#1787
Belphemur merged 9 commits intodevfrom
Belphemur/issue1786

Conversation

@Belphemur
Copy link
Owner

Fixes #1786

@Belphemur Belphemur requested a review from Copilot May 23, 2025 13:14
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Belphemur, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello team, gemini-code-assist here to provide a summary of this pull request. This PR introduces functionality into the installer to check for and, if necessary, trigger the installation of a specific Windows Update (KB5053606). This check and potential installation is specifically targeted at Windows 10 LTSC (Long-Term Servicing Channel) editions. The logic is implemented using a new PowerShell script that interacts with the Windows Update service, orchestrated by a new Inno Setup include script. The prerequisite check and trigger happen during the installer's initialization phase, and the KB installation attempt is non-blocking, allowing the main application installation to proceed regardless of the update's success or failure.

Highlights

  • Windows Update Prerequisite: Adds a check for the presence of KB5053606 during the installation process.
  • LTSC Specific Logic: The prerequisite check and potential update installation are only performed on Windows 10 Enterprise LTSC or LTSB systems.
  • PowerShell Integration: A new PowerShell script is introduced to handle the actual interaction with the Windows Update service (checking if a KB is installed and triggering its installation).
  • Installer Integration: The logic is integrated into the Inno Setup script, calling the PowerShell script via a new helper include file during the InitializeSetup phase.
  • Non-Blocking Update Trigger: The attempt to install the required KB is launched without waiting for its completion, ensuring the main application installation doesn't hang.

Changelog

Click here to see the changelog
  • Installer/scripts/ManageWindowsUpdate.ps1
    • New PowerShell script added.
    • Includes functions to log output with timestamps.
    • Provides Test-KBInstalled function using Get-HotFix and WMI to check for a specific KB.
    • Provides Invoke-KBInstall function using Windows Update COM objects to search, download, and install a specific KB.
    • Uses specific exit codes to indicate status (installed, not installed, errors, etc.).
  • Installer/scripts/windows_update_helper.iss
    • New Inno Setup include script added.
    • Defines constants for the target KB ID (KB5053606) and LTSC product names.
    • Includes functions to log messages specific to the update helper.
    • Adds IsWin10LTSC_WU function to detect Windows 10 LTSC/LTSB via registry check.
    • Adds FindPowerShell_WU function to locate the powershell.exe executable.
    • Adds IsKBInstalledPS_WU function to call the PowerShell script for KB status check.
    • Adds AttemptKBInstallPS_WU procedure to call the PowerShell script to trigger KB installation (using ewNoWait).
    • Adds InitializeSetup_WindowsUpdatePrerequisites function to orchestrate the LTSC check, PowerShell finding, KB check, and KB install trigger.
  • Installer/setup.iss
    • Adds scripts\ManageWindowsUpdate.ps1 to the list of files copied to the temporary directory during setup (line 83).
    • Includes the new scripts\windows_update_helper.iss file (line 124).
    • Modifies the InitializeSetup function to call InitializeSetup_WindowsUpdatePrerequisites from the helper script (line 127-145).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


An installer runs,
Checks for updates, PowerShell hums,
LTSC needs patch.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request addresses issue #1786 by adding Windows Update prerequisite checks and installation logic to the installer. Key changes include:

  • Modification of Installer/setup.iss to include and invoke a Windows Update helper script.
  • Addition of Installer/scripts/windows_update_helper.iss containing helper functions for checking the OS version and KB installation status.
  • New PowerShell script in Installer/scripts/ManageWindowsUpdate.ps1 to perform KB checks and trigger update installations.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Installer/setup.iss Includes new Windows Update script and updates the InitializeSetup logic to call the helper.
Installer/scripts/windows_update_helper.iss Adds helper functions and logging for Windows Update prerequisite checks.
Installer/scripts/ManageWindowsUpdate.ps1 Implements PowerShell logic for checking and triggering KB update installations.

Comment on lines +131 to +144
if InitializeSetup_WindowsUpdatePrerequisites() then
begin
// Prerequisite check passed (or silently continued as per its design)
// Add any other main InitializeSetup logic here if needed in the future.
// For now, just return True as the helper handles its own logic and always returns True.
Result := True;
end
else
begin
// This path should ideally not be taken if the helper function is designed to always return True.
// However, as a robust measure:
Log('Main InitializeSetup: Call to InitializeSetup_WindowsUpdatePrerequisites returned False. This is unexpected given the silent failure design.');
Result := True; // Still proceed with installation as per overall "silent failure" requirement.
end;
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of the conditional in InitializeSetup() return True. Consider simplifying this logic by removing the unnecessary false branch if the helper function is designed to always succeed.

Suggested change
if InitializeSetup_WindowsUpdatePrerequisites() then
begin
// Prerequisite check passed (or silently continued as per its design)
// Add any other main InitializeSetup logic here if needed in the future.
// For now, just return True as the helper handles its own logic and always returns True.
Result := True;
end
else
begin
// This path should ideally not be taken if the helper function is designed to always return True.
// However, as a robust measure:
Log('Main InitializeSetup: Call to InitializeSetup_WindowsUpdatePrerequisites returned False. This is unexpected given the silent failure design.');
Result := True; // Still proceed with installation as per overall "silent failure" requirement.
end;
if not InitializeSetup_WindowsUpdatePrerequisites() then
begin
// Log a warning if the helper function unexpectedly returns False.
Log('Main InitializeSetup: Call to InitializeSetup_WindowsUpdatePrerequisites returned False. This is unexpected given the silent failure design.');
end;
// Always proceed with installation as per the silent failure requirement.
Result := True;

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +159
if ($installationResult.ResultCode -eq 2) {
# or suSucceeded
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of '2' as the success code for the installation result may not be immediately clear. Consider defining a named constant or adding a comment to clarify why 2 represents a successful update installation.

Suggested change
if ($installationResult.ResultCode -eq 2) {
# or suSucceeded
if ($installationResult.ResultCode -eq $SUCCEEDED_RESULT_CODE) {
# or suSucceeded (represented by $SUCCEEDED_RESULT_CODE)

Copilot uses AI. Check for mistakes.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a mechanism to check for and initiate the installation of a specific Windows Update KB during the setup process. It introduces a PowerShell script for Windows Update interaction and an Inno Setup helper script to manage this. The changes are generally well-implemented, but there are a few areas that could be refined for robustness and clarity.

Summary of Findings

  • PowerShell Search Criteria Efficiency: The PowerShell script ManageWindowsUpdate.ps1 uses a very broad search criterion (L67) for Windows Updates, which could be inefficient. A more targeted search might improve performance.
  • Dead Code in PowerShell Script: There's a block of code in ManageWindowsUpdate.ps1 (L122-125) that appears to be unreachable given the preceding logic.
  • PowerShell Path Validation in Inno Setup: The logic in windows_update_helper.iss (L133-142) for validating the PowerShell executable path, especially when relying on the system PATH, could be more robust to ensure PowerShell is truly accessible.
  • PowerShell KBID Parsing Robustness: In ManageWindowsUpdate.ps1 (L93), the KBID parsing assumes the input $KBID is always 'KB' (uppercase) followed by numbers. Consider making it case-insensitive.
  • Inno Setup File Flags: In setup.iss (L83), the confirmoverwrite flag for a file copied to {tmp} is unusual. overwrite might be more appropriate.
  • Inno Setup InitializeSetup Logic: The InitializeSetup function in setup.iss (L131-143) has a slightly verbose if/else structure. This could be simplified.

Merge Readiness

The pull request is a good step towards addressing issue #1786. However, there are a few medium-severity issues identified related to script robustness and potential dead code that should be addressed before merging, as well as some low severity issues. Once these are resolved, the changes should be in good shape. As an AI, I am not authorized to approve pull requests; please ensure further review and approval from authorized maintainers.

Comment on lines +122 to +125
if ($updatesToDownload.Count -eq 0) {
Write-LogOutput "No updates matching $KBID require downloading or installation (already downloaded or not found)."
Exit 0 # Or appropriate code if it means already installed/not applicable
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code if ($updatesToDownload.Count -eq 0) appears to be unreachable under normal execution flow.

Here's why:

  1. To reach this point, $updateFound (line 109) must have been set to $true.
  2. If $updateFound is $true, an update was added to $updatesToDownload on line 108.
  3. Therefore, $updatesToDownload.Count should be 1 (due to the break on line 113).
  4. If $updateFound were $false, the script would have exited on line 119.

This suggests the condition $updatesToDownload.Count -eq 0 will not be met here.

Could you clarify the purpose of this block or consider removing it if it's indeed dead code? If it's intended as a safeguard for an unexpected state, perhaps a more specific error log/exit code would be appropriate.

@Belphemur Belphemur force-pushed the Belphemur/issue1786 branch from c70b057 to e184772 Compare May 23, 2025 13:19
@Belphemur Belphemur force-pushed the Belphemur/issue1786 branch from 8c9449d to c1dd9a9 Compare May 23, 2025 17:58
fix: update runner version to windows-2025 in test installer build workflow

fix: install Inno Setup with machine scope in workflow

fix: use dummy script for SignTool in installer test workflow

feat: pass SignTool override to Make-Installer.bat from workflow

feat: update Make.bat and workflow for SignTool override and .NET 9

ci: enable dotnet cache in test installer workflow

fix: add cache-dependency-path for .NET 9.0 setup in test installer workflow

ci: add SoundSwitch application build step before installer build

feat: add verbose output to Make-Installer.bat script

fix: properly handle parameters with special characters in batch scripts

fix: use direct parameter passing to avoid variable expansion issues in Make-Installer.bat

fix: simplify parameter handling by constructing /SCertum= in Make-Installer.bat

ci: add asset preparation step in test installer build workflow

ci: update concurrency settings for test installer build workflow

ci: fix signtool

ci: modify setup.iss in workflow to remove signing for test builds

- Add step to remove SignTool, SignedUninstaller, and signonce flags from setup.iss
- Simplify Make-Installer.bat to only accept release state parameter
- Eliminates complex parameter passing for signing configuration
- Enables clean unsigned installer builds for testing purposes
@Belphemur Belphemur force-pushed the Belphemur/issue1786 branch from 27730d1 to 4de3f36 Compare May 23, 2025 18:32
@Belphemur Belphemur enabled auto-merge May 23, 2025 18:45
@Belphemur Belphemur disabled auto-merge May 23, 2025 18:46
@Belphemur Belphemur enabled auto-merge May 23, 2025 18:46
@Belphemur Belphemur merged commit 26173ef into dev May 23, 2025
9 checks passed
@Belphemur Belphemur deleted the Belphemur/issue1786 branch May 23, 2025 18:47
@github-actions
Copy link
Contributor

🎉 This PR is included in version 6.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect missing Windows Update on Win10 LTSC

2 participants