Skip to content

insovs/Device-Cleanup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

Repository files navigation

Device Cleanup

Scans and removes ghost devices left behind by previously connected hardware — reducing IRQ overhead, lowering input latency, and making input smoother. Everything runs natively through Windows built-in tools. It is safe, and non-destructive.

  • Ghost devices are phantom registry entries from hardware that is no longer connected.
  • They silently consume IRQ resources and can cause input stutter, slower USB initialization, and driver conflicts.

Note

Not sure what it does? Check the video preview to see it in action. the whole process takes under 10 seconds.

preview

📸 Screenshots

Scan results — ghost devices detected and listed, protected devices preserved

All detected devices are displayed with their status. Ghost devices (GHOST) are pre-checked and ready for removal. Devices with CPU affinity / IRQ pinning (AFFINITY CONFIGURED) are listed separately and unchecked by default.

Scan results


Confirm removal — one-click removal with confirmation dialog

Before any deletion, a confirmation popup displays the exact number of devices to be removed. The action cannot be undone through this tool — though devices will re-appear if the hardware is reconnected.

Confirm removal


After removal — clean state, only protected devices remain

After removal, the tool automatically re-scans. Ghost count drops to 0, removed count updates to reflect the session total. Only AFFINITY CONFIGURED devices remain, fully intact.

After removal


Why it matters

Every time you plug in a peripheral — mouse, keyboard, USB hub, headset — Windows registers it. When you unplug it, the entry stays. Over time, these stale entries pile up silently in the registry, consuming IRQ resources and creating noise in the device enumeration process.

Device Cleanup scans every registered device on your system, identifies the ones no longer physically present, and removes them in a single operation. The result is a cleaner interrupt table, faster USB initialization, and smoother input — with zero guesswork.

All changes are limited to phantom entries. Active devices and any device with CPU affinity or IRQ pinning configured are never touched. If a removed device is reconnected, Windows will simply re-detect it as new — no data is permanently lost and fully safe !


Support

If you need any help or have questions, feel free to join the Discord support server — I'll be happy to assist you.

Installation & Launch

Download DeviceCleanup.ps1, then right-click it → "Run with PowerShell".
The script will automatically request administrator privileges.

Caution

If you are not allowed to run PowerShell scripts, enable it first:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Or refer to EnablePowerShellScript.

Usage

  1. Click Scan System — the tool scans all devices registered in Windows, including disconnected ones.
  2. Review the list — ghost devices are listed as GHOST, protected devices as AFFINITY CONFIGURED.
  3. Select the devices to remove (all ghosts are pre-checked by default).
  4. Click Remove Selected and confirm.
  5. The tool automatically re-scans after removal to confirm they are gone.

What the tool does

Feature Description
Ghost device scan Detects all devices with status Unknown (Error Code 45) — hardware no longer connected.
Affinity protection Automatically preserves any device with a CPU affinity / IRQ pinning configuration.
Safe removal Removes ghost entries using up to 5 fallback methods — Remove-PnpDevice, pnputil, SetupAPI, reg.exe, devcon.

Device categories

Label Meaning
GHOST Phantom device — previously connected, no longer present. Safe to remove.
AFFINITY CONFIGURED Device has IRQ / CPU affinity pinning configured. Protected by default, removable manually.

Important

Devices marked AFFINITY CONFIGURED are unchecked by default. Removing them will delete your IRQ affinity configuration. Only do so intentionally.

Benefits

Gains scale with the number of devices removed. Results are most noticeable on systems with a large number of previously connected peripherals.

Improvement Details
Lower input latency Fewer phantom IRQ entries competing for resources.
No IRQ conflicts Cleaner interrupt routing across active devices.
Faster USB initialization Windows no longer enumerates stale device entries.
Faster boot Reduced device enumeration on startup.
Cleaner registry Removes dead entries under HKLM\SYSTEM\CurrentControlSet\Enum.

Removal method chain

The tool attempts removal using the following methods in order, stopping at the first success:

  1. Remove-PnpDevice — native PowerShell cmdlet
  2. pnputil.exe /remove-device — Windows built-in PnP utility
  3. SetupAPI SetupDiRemoveDevice — direct Win32 API call, bypasses PnP manager lock
  4. reg.exe delete — brute-force registry key removal
  5. devcon.exe remove — if present on system or in script directory

About this project

This is an improved and redesigned version of the original Device Cleanup Tool by Uwe Sieber.
Built from scratch with a modern GUI, it adds automatic protection for devices with CPU affinity / IRQ pinning configured — keeping them clearly identified and unchecked by default, so nothing gets removed by accident.
The interface also provides a clearer real-time view of what is happening at each step, making the whole process more intuitive for everyone.


©insopti — guns.lol/inso.vs | For personal use only.

About

PowerShell GUI to scan and remove ghost devices left by disconnected hardware. Reduces IRQ overhead, lowers input latency and cleans stale registry entries. Fully safe & non-destructive.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors