Skip to content

fix(system): correct sc.exe argument syntax, reg deletion, and ipv6 dns guard - #4966

Open
virtualtable wants to merge 3 commits into
ChrisTitusTech:mainfrom
virtualtable:fix/system-helpers-and-impex
Open

fix(system): correct sc.exe argument syntax, reg deletion, and ipv6 dns guard#4966
virtualtable wants to merge 3 commits into
ChrisTitusTech:mainfrom
virtualtable:fix/system-helpers-and-impex

Conversation

@virtualtable

Copy link
Copy Markdown

Description

Fixes sc.exe argument syntax, replaces invalid REG DELETE drive paths in Windows Update repair, guards IPv6 DNS configuration, and adds backward-compatibility for legacy JSON config imports.

Changes Included

  1. Set-WinUtilService.ps1: Added mandatory space after start= for sc.exe config.
  2. Invoke-WPFFixesUpdate.ps1: Replaced invalid REG DELETE HKLM:... drive paths with native PowerShell Remove-ItemProperty.
  3. Set-WinUtilDNS.ps1: Added ipv6Addresses count check before calling Set-DnsClientServerAddress.
  4. Invoke-WPFImpex.ps1: Implemented property flattening for legacy JSON export structures.

Verification

  • Ran Compile.ps1 to verify clean build generation.
  • No hand edits were made to winutil.ps1.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 369360f4-f5f1-484e-a71f-2775873e34e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved IPv6 DNS configuration when no IPv6 addresses are specified.
    • Corrected delayed automatic service startup configuration and error handling.
    • Improved cleanup of outdated WSUS client identifiers.
    • Enhanced import handling for legacy configurations, including better detection and processing of saved settings.

Walkthrough

The changes update IPv6 DNS handling, delayed service startup configuration, WSUS registry cleanup, and legacy configuration import processing.

Changes

Windows utility maintenance

Layer / File(s) Summary
Network and service configuration
functions/private/Set-WinUtilDNS.ps1, functions/private/Set-WinUtilService.ps1
IPv6 DNS configuration runs only when IPv6 addresses exist. Delayed automatic service startup uses start= delayed-auto and throws on command failure.
WSUS registry cleanup
functions/public/Invoke-WPFFixesUpdate.ps1
The three WSUS values are removed with Remove-ItemProperty. Silent error handling remains enabled.
Legacy import processing
functions/public/Invoke-WPFImpex.ps1
Legacy objects with an Install property are detected and flattened. Newer configuration objects continue to use parsed JSON directly.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: bug

Suggested reviewers: christitustech

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main fixes to sc.exe syntax, registry deletion, and IPv6 DNS handling.
Description check ✅ Passed The description accurately covers all four changes and the stated verification steps.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@functions/private/Set-WinUtilService.ps1`:
- Line 36: Update the service configuration flow around sc.exe config in
Set-WinUtilService so it checks $LASTEXITCODE immediately after the command and
throws when the exit code is non-zero. Keep the success log only on the
successful path, allowing the existing catch handling to report configuration
failures.

In `@functions/public/Invoke-WPFImpex.ps1`:
- Around line 76-86: The legacy-import flattening logic around $flattenedJson
must exclude the metadata object represented by the Install property before
Update-WinUtilSelections is called, retaining only selection identifiers and
preserving flat-import behavior. Add a regression fixture that verifies legacy
and flat imports produce equivalent selections.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b64fa5d-4c41-4263-b7f5-9ee0229a183c

📥 Commits

Reviewing files that changed from the base of the PR and between ea5de27 and 60a541d.

📒 Files selected for processing (4)
  • functions/private/Set-WinUtilDNS.ps1
  • functions/private/Set-WinUtilService.ps1
  • functions/public/Invoke-WPFFixesUpdate.ps1
  • functions/public/Invoke-WPFImpex.ps1

Comment thread functions/private/Set-WinUtilService.ps1
Comment thread functions/public/Invoke-WPFImpex.ps1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60a541d1cf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +79 to +81
foreach ($prop in $jsonFile.PSObject.Properties) {
if ($null -ne $prop.Value) {
$flattenedJson += @($prop.Value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip legacy Install metadata when flattening imports

When a legacy config includes selected install apps, the legacy Install property contains package metadata objects while the checkbox keys are under WPFInstall (the removed flattening comment also excluded Install). This loop now appends every property value, so those metadata objects get passed to Update-WinUtilSelections, don't match any WPF* prefix, and leave $listName null before .Add(...), causing the import to error or leave only a partial selection; filter out Install or only flatten the checkbox-key groups.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Aug 11, 2026
@virtualtable

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@virtualtable

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mewclouds

Copy link
Copy Markdown
Contributor

Thanks for working on this. I raised the same concern on #4911, but a decision has not been made in #4877 about what backward compatibility should mean here.

The backup format changed on February 17, almost six months ago. It is up to Chris to decide whether full compatibility is necessary or partial import is acceptable.

This skips the old Install section. That may be necessary because the old winget and choco metadata cannot be passed directly to the current selection importer, but it also means the backup is not necessarily fully restored. That needs an explicit product decision rather than being presented as complete backward compatibility.

I also cannot verify this was tested. There is no legacy JSON fixture, import-path test, or example of the old input and expected selections.

Finally, every provider in config/dns.json has Primary6 and Secondary6, so the IPv6 guard is always true. IPv4-only DNS providers are very rare.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants