Skip to content

Devices: native removal of ghost (non-present) devices - #36

Merged
PrimeBuild-pc merged 1 commit into
mainfrom
claude/ghost-devices-2f9127
Nov 15, 2026
Merged

PrimeBuild-pc merged 1 commit into
mainfrom
claude/ghost-devices-2f9127

Conversation

@PrimeBuild-pc

Copy link
Copy Markdown
Owner

Closes #35.

What changes

  • Devices page → "Remove ghost devices": lists every non-present device and removes the ticked ones with pnputil /remove-device, through the existing elevated, hash-approved script flow.
  • Filter (same rules as DriverStore Explorer PR Add Remove Ghost Devices action lostindark/DriverStoreExplorer#514):
    • only Present = false devices are listed; present devices are never touched;
    • devices that TweakHub disabled are left out, so "Re-enable all" keeps tracking them;
    • hardware ghosts are ticked; software-enumerated ones (ROOT\, SWD\, SW\, UMB\, HTREE\, {GUID} buses) are listed but not ticked, because some are hidden on purpose and still needed.
  • The script re-reads DEVPKEY_Device_IsPresent right before each removal, so a device reconnected meanwhile is skipped (SKIP).
  • The confirmation states that removal cannot be undone from TweakHub: Windows recreates the device only when it detects it again, and its settings may be lost. After the run, a summary shows "removed X of Y" and the devices not removed, then the list refreshes.
  • AppDialog choice lists now scroll (max 360 px) and wrap, so a long list (80–170 ghosts) keeps the buttons on screen.
  • Strings in all 6 locales (Resources/Devices*.resx).
  • The Tools link to the external Device Cleanup Tool stays as an alternative (it also offers registry cleanup and scheduling).

Tests

  • New unit test GhostRemovalListsOnlyNotPresentDevicesAndTicksOnlyHardwareOnes; the removal script was added to the PowerShell parse test.
  • dotnet build -c Release: 0 errors, 0 warnings. dotnet test: 414/414 passed.
  • End-to-end on a Hyper-V Windows 11 VM, running the compiled DeviceService methods against the guest: 150 devices, 64 present, 86 ghosts, 82 ticked → 82 removed, 0 failed. A present device added to the list on purpose was skipped. Afterwards the guest had 64 present and 4 ghosts (the unticked software ones), and no removed device was listed by Get-PnpDevice. The VM was then restored to its clean checkpoint.
  • Not covered: the click-through in the WPF dialog inside the VM. The UI path was only built, not driven.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T14:48:41.165246Z
We couldn’t complete this review. Comment @codex review to try again.
2262441 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Adds "Remove ghost devices" to the Devices page. It lists every
non-present device (except ones TweakHub disabled, which stay tracked for
"Re-enable all"), ticks hardware ghosts and leaves software-enumerated ones
(ROOT, SWD, SW, UMB, HTREE, GUID buses) unticked. One elevated script
re-reads DEVPKEY_Device_IsPresent before each `pnputil /remove-device`, so
a device plugged in meanwhile is skipped; the result dialog shows removed
and not-removed devices, then the list refreshes. The dialog states that
removal cannot be undone from TweakHub.

The choice list in AppDialog now scrolls and wraps, so long lists keep the
buttons on screen.

Closes #35
@PrimeBuild-pc
PrimeBuild-pc merged commit 156dccd into main Nov 15, 2026
1 check passed
@PrimeBuild-pc
PrimeBuild-pc deleted the claude/ghost-devices-2f9127 branch November 15, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Devices: native ghost (non-present) device removal

1 participant