Conversation
There was a problem hiding this comment.
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
InitializeSetupphase. - 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-KBInstalledfunction usingGet-HotFixand WMI to check for a specific KB. - Provides
Invoke-KBInstallfunction 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_WUfunction to detect Windows 10 LTSC/LTSB via registry check. - Adds
FindPowerShell_WUfunction to locate the powershell.exe executable. - Adds
IsKBInstalledPS_WUfunction to call the PowerShell script for KB status check. - Adds
AttemptKBInstallPS_WUprocedure to call the PowerShell script to trigger KB installation (usingewNoWait). - Adds
InitializeSetup_WindowsUpdatePrerequisitesfunction to orchestrate the LTSC check, PowerShell finding, KB check, and KB install trigger.
- Installer/setup.iss
- Adds
scripts\ManageWindowsUpdate.ps1to the list of files copied to the temporary directory during setup (line 83). - Includes the new
scripts\windows_update_helper.issfile (line 124). - Modifies the
InitializeSetupfunction to callInitializeSetup_WindowsUpdatePrerequisitesfrom the helper script (line 127-145).
- Adds
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
-
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. ↩
There was a problem hiding this comment.
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. |
| 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; |
There was a problem hiding this comment.
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.
| 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; |
| if ($installationResult.ResultCode -eq 2) { | ||
| # or suSucceeded |
There was a problem hiding this comment.
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.
| if ($installationResult.ResultCode -eq 2) { | |
| # or suSucceeded | |
| if ($installationResult.ResultCode -eq $SUCCEEDED_RESULT_CODE) { | |
| # or suSucceeded (represented by $SUCCEEDED_RESULT_CODE) |
There was a problem hiding this comment.
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.ps1uses 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$KBIDis always 'KB' (uppercase) followed by numbers. Consider making it case-insensitive. - Inno Setup File Flags: In
setup.iss(L83), theconfirmoverwriteflag for a file copied to{tmp}is unusual.overwritemight be more appropriate. - Inno Setup InitializeSetup Logic: The
InitializeSetupfunction insetup.iss(L131-143) has a slightly verboseif/elsestructure. 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.
| 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 | ||
| } |
There was a problem hiding this comment.
This block of code if ($updatesToDownload.Count -eq 0) appears to be unreachable under normal execution flow.
Here's why:
- To reach this point,
$updateFound(line 109) must have been set to$true. - If
$updateFoundis$true, an update was added to$updatesToDownloadon line 108. - Therefore,
$updatesToDownload.Countshould be 1 (due to thebreakon line 113). - If
$updateFoundwere$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.
c70b057 to
e184772
Compare
8c9449d to
c1dd9a9
Compare
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
27730d1 to
4de3f36
Compare
|
🎉 This PR is included in version 6.14.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fixes #1786