Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon Cache Repair

PowerShell Version Platform License PRs Welcome

A modern, robust, and safe PowerShell script to fix corrupted, missing, blank, or black icons in Windows (10/11) by purging the icon and thumbnail cache files. No Administrator privileges required.

Note

This tool features a built-in fail-safe mechanism that guarantees explorer.exe will restart under all circumstances, even if the script is abruptly aborted (e.g., via Ctrl + C).


Compatibility

Environment Supported Versions Notes
Operating System Windows 10 / Windows 11 Full purge for legacy .db and modern .dat caches
PowerShell 5.1, 7.x+ (Core) Native support with zero external dependencies
Privileges Standard User Runs completely in user-space (No Admin required)

Features

  • No Admin Rights Required: Runs completely in user space—safe and easy to run on enterprise or personal machines.
  • Modern Windows 11 Support: Purges both legacy .db cache files and modern .dat explorer caches.
  • Interactive Console UI: Features a sleek ANSI animated banner and a smooth terminal spinner.
  • Robust Fail-Safe (try-finally): Employs try-finally structures to guarantee that Windows Explorer restarts even if the script is manually interrupted or throws an error.
  • Taskkill Forced Release: Uses forced process termination followed by a release sleep buffer to properly unlock file handles prior to deletion, preventing "File in use" errors.
  • Silent Mode Support: Perfect for automation, deployment via GPO/SCCM, or integrating into custom scripts (-Silent switch).

How It Works

The script executes a precise 6-step repair process:

  1. Detects Explorer: Checks if explorer.exe is currently running and captures its process ID safely.
  2. Forcibly Stops Explorer: Terminates explorer.exe using taskkill and waits for file handle locks to be released.
  3. Scans Cache Directories: Automatically targets localized user app data where Windows stores icon/thumbnail caches.
  4. Deletes Cache Files: Safely deletes legacy IconCache.db and advanced registry-based explorer cache formats.
  5. Restarts Explorer: Recovers the desktop environment by launching explorer.exe back up.
  6. Forces Icon Refresh: Performs a deep shell refresh utilizing user parameter updates and ie4uinit.exe -show triggers to instantly apply the fixes.

Quick Start and Usage

Method 1: Interactive Menu (Recommended)

  1. Download IconCacheRepair.ps1 to your computer.
  2. Open PowerShell (Standard/Non-Admin is perfectly fine).
  3. Navigate to the directory containing the script:
    cd Path\To\Script
  4. Run the script:
    powershell -ExecutionPolicy Bypass -File .\IconCacheRepair.ps1
  5. Choose option [1] to start the repair.

Method 2: One-Liner (Run directly from Web)

Run the script directly via PowerShell without manually downloading the file:

irm "https://raw.githubusercontent.com/AmrKhalid-dev/Icon-Cache-Repair/main/IconCacheRepair.ps1" | iex

Method 3: Silent Execution (For Admins and Automation)

To run the repair silently without any UI or prompts (returns 0 on success, 1 on failure):

powershell -ExecutionPolicy Bypass -File .\IconCacheRepair.ps1 -Silent

Security and Failsafes

This script was crafted with standard enterprise development practices to ensure no data loss or workspace disruption occurs:

  • Strict Mode: Runs under Set-StrictMode -Version Latest to prevent unexpected variables or syntax errors.
  • Finally Safeguard:
    finally {
        if (-not (Get-ExplorerProcess)) {
            Start-Process "explorer.exe" -ErrorAction SilentlyContinue | Out-Null
        }
    }
    Even if the user presses Ctrl + C during step 3 or 4, Windows Explorer will recover instantly.

Screenshots

Main Interactive Menu

Main Interactive Menu

Repairing Process

Repairing Process


Support & Troubleshooting

If your icons are still not rendering correctly after running this script:

  1. Restart your Computer: Some shell extensions or 3rd-party software lock icon handlers until a full system reboot.
  2. Report a Bug: If you encounter any unexpected error, please Open an Issue providing your Windows version and script output.

Governance & Security

  • Security Policy: To report security concerns or vulnerabilities, please review our Security Policy.
  • Contributions: Contributions are welcome! Please feel free to open a Pull Request or report issues in the tracker.

Author

Created by Amr Khalid Al-Mosabi (@AmrKhalid-dev)

  • Support the project by giving it a ⭐ on GitHub!

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A modern, robust, and safe PowerShell script to fix corrupted, missing, blank, or black icons in Windows (10/11).

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages