木子屋 Dnawo's BLOG

批处理一键清除Windows操作系统应用图标缓存

👤 dnawo 📅 2026-12-02 👁 26 👍 0 💬 0 🔄 本站原创 📂 操作系统
在Windows窗体应用程序开发时经常碰到一个问题,更换应用程序图标后重新编译生成应用程序,结果exe文件图标仍是旧的,复制到其他文件夹图标就正常,这是因为Windows系统缓存了图标,让WorkBuddy写了一个批处理一键清除图标缓存(refresh_icon_cache.bat):

@echo off
setlocal
echo ============================================
echo   Windows Icon Cache Refresh
echo ============================================
echo.
echo This will restart Windows Explorer briefly.
echo Your desktop and taskbar will blink once - this is normal.
echo.
pause

rem LOCALAPPDATA exists since Vista; fall back to XP path
set "LAD=%LOCALAPPDATA%"
if "%LAD%"=="" set "LAD=%USERPROFILE%\Local Settings\Application Data"

echo [1/3] Stopping Windows Explorer...
taskkill /F /IM explorer.exe >nul 2>&1

rem ping is used as a delay because it exists on every Windows version
ping -n 2 127.0.0.1 >nul 2>&1

echo [2/3] Deleting icon cache files...
del /F /Q "%LAD%\IconCache.db" >nul 2>&1
del /F /Q "%LAD%\Microsoft\Windows\Explorer\iconcache_*.db" >nul 2>&1
del /F /Q "%LAD%\Microsoft\Windows\Explorer\thumbcache_*.db" >nul 2>&1

echo [3/3] Restarting Windows Explorer...
start "" explorer.exe

echo.
echo Done. Wait a few seconds for the desktop to settle,
echo then check the IcbcGoldDesktop.exe icon again.
echo If it is still old, log off and log back in once.
echo.
pause

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 【API】上金所Au9999黄金价格接口文档