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).
| 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) |
- 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
.dbcache files and modern.datexplorer caches. - Interactive Console UI: Features a sleek ANSI animated banner and a smooth terminal spinner.
- Robust Fail-Safe (
try-finally): Employstry-finallystructures 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 (
-Silentswitch).
The script executes a precise 6-step repair process:
- Detects Explorer: Checks if
explorer.exeis currently running and captures its process ID safely. - Forcibly Stops Explorer: Terminates
explorer.exeusingtaskkilland waits for file handle locks to be released. - Scans Cache Directories: Automatically targets localized user app data where Windows stores icon/thumbnail caches.
- Deletes Cache Files: Safely deletes legacy
IconCache.dband advanced registry-based explorer cache formats. - Restarts Explorer: Recovers the desktop environment by launching
explorer.exeback up. - Forces Icon Refresh: Performs a deep shell refresh utilizing user parameter updates and
ie4uinit.exe -showtriggers to instantly apply the fixes.
- Download
IconCacheRepair.ps1to your computer. - Open PowerShell (Standard/Non-Admin is perfectly fine).
- Navigate to the directory containing the script:
cd Path\To\Script
- Run the script:
powershell -ExecutionPolicy Bypass -File .\IconCacheRepair.ps1
- Choose option
[1]to start the repair.
Run the script directly via PowerShell without manually downloading the file:
irm "https://raw.githubusercontent.com/AmrKhalid-dev/Icon-Cache-Repair/main/IconCacheRepair.ps1" | iexTo run the repair silently without any UI or prompts (returns 0 on success, 1 on failure):
powershell -ExecutionPolicy Bypass -File .\IconCacheRepair.ps1 -SilentThis script was crafted with standard enterprise development practices to ensure no data loss or workspace disruption occurs:
- Strict Mode: Runs under
Set-StrictMode -Version Latestto prevent unexpected variables or syntax errors. - Finally Safeguard:
Even if the user presses
finally { if (-not (Get-ExplorerProcess)) { Start-Process "explorer.exe" -ErrorAction SilentlyContinue | Out-Null } }
Ctrl + Cduring step 3 or 4, Windows Explorer will recover instantly.
If your icons are still not rendering correctly after running this script:
- Restart your Computer: Some shell extensions or 3rd-party software lock icon handlers until a full system reboot.
- Report a Bug: If you encounter any unexpected error, please Open an Issue providing your Windows version and script output.
- 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.
Created by Amr Khalid Al-Mosabi (@AmrKhalid-dev)
- Support the project by giving it a ⭐ on GitHub!
This project is licensed under the MIT License - see the LICENSE file for details.