Skip to content

How to Clear the Font Cache in Batch Script

Learn how to safely reset Windows font cache using batch scripts to fix garbled text, wrong typefaces, and missing glyphs by stopping font services and deleting corrupt cache files.

Font cache corruption is a subtle but frustrating Windows issue that causes text to render as garbled characters, wrong typefaces, squared symbols, or missing glyphs in applications like Office, browsers, and design tools. Windows caches font metadata and rendered bitmaps to speed up text display. When this cache becomes damaged, the only fix is to stop the font services, delete the cache files, and let Windows rebuild from the original font files.

This guide explains how to safely reset the font cache with proper service management and file deletion.

Understanding the Font Cache

Font Rendering Pipeline:
  Application requests font → Font Cache Service checks cache
    ├── Cache hit:  Return cached glyph data (fast)
    └── Cache miss: Read from C:\Windows\Fonts → render → cache → return

When cache is corrupt:
  Application requests font → Cache returns garbage data
    → Wrong characters, boxes, or rendering failures

Cache file locations:

File/Path Purpose Service
%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache\*.dat Main font metric and bitmap cache FontCache
%WinDir%\System32\FNTCACHE.DAT Boot-time font cache (loaded early in startup) System
%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache-* Additional font cache directories (Windows 10/11) FontCache

Services involved:

Service Name Display Name Purpose
FontCache Windows Font Cache Service Caches font data for applications
FontCache3.0.0.0 Windows Presentation Foundation Font Cache Caches fonts for WPF applications (.NET/XAML apps)

Both services must be stopped before cache files can be deleted, because they hold file locks on the cache databases.

Method 1: Complete Font Cache Reset

This method stops both font cache services, deletes all cache files from all known locations, restarts the services, and verifies the cleanup.

@echo off
setlocal

echo ============================================================
echo   Windows Font Cache Repair Utility
echo ============================================================
echo.

:: Check admin rights
net session >nul 2>&1
if errorlevel 1 (
    echo [ERROR] This script must be run as Administrator. >&2
    echo Right-click and select "Run as administrator." >&2
    endlocal
    exit /b 1
)

echo [OK] Running with administrator privileges.
echo.

:: =============================================
:: Step 1: Stop font cache services
:: =============================================
echo [1/4] Stopping font cache services...

:: Stop the primary font cache service
net stop FontCache >nul 2>&1
sc query FontCache 2>nul | findstr /i "STOPPED" >nul 2>&1
if not errorlevel 1 (
    echo   [OK] FontCache stopped.
) else (
    echo   [RETRY] FontCache did not stop immediately. Waiting...
    timeout /t 5 /nobreak >nul
    net stop FontCache >nul 2>&1
    sc query FontCache 2>nul | findstr /i "STOPPED" >nul 2>&1
    if not errorlevel 1 (
        echo   [OK] FontCache stopped (after retry^).
    ) else (
        echo   [WARNING] FontCache could not be stopped. >&2
        echo   Close all applications and try again, or reboot. >&2
    )
)

:: Stop the WPF font cache service
net stop "FontCache3.0.0.0" >nul 2>&1
sc query "FontCache3.0.0.0" 2>nul | findstr /i "STOPPED" >nul 2>&1
if not errorlevel 1 (
    echo   [OK] WPF Font Cache stopped.
) else (
    :: This service may not exist on all systems
    sc query "FontCache3.0.0.0" >nul 2>&1
    if errorlevel 1060 (
        echo   [INFO] WPF Font Cache service not found (normal on some systems^).
    ) else (
        echo   [WARNING] WPF Font Cache could not be stopped. >&2
    )
)

echo.

:: =============================================
:: Step 2: Delete font cache files
:: =============================================
echo [2/4] Deleting font cache files...

set "Deleted=0"
set "Failed=0"

:: Location 1: Main font cache directory
set "CacheDir1=%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache"
if exist "%CacheDir1%\" (
    for %%f in ("%CacheDir1%\*.*") do (
        del /f /q "%%f" 2>nul
        if not exist "%%f" (
            set /a "Deleted+=1"
        ) else (
            set /a "Failed+=1"
            echo   [FAIL] %%~nxf >&2
        )
    )
    echo   [OK] FontCache directory processed.
) else (
    echo   [INFO] FontCache directory not found, may use alternative location.
)

:: Location 2: Font cache subdirectories (FontCache-S-1-5-*, etc.)
for /d %%d in ("%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache-*") do (
    for %%f in ("%%d\*.*") do (
        del /f /q "%%f" 2>nul
        if not exist "%%f" set /a "Deleted+=1"
    )
)

:: Location 3: Boot-time font cache
if exist "%WinDir%\System32\FNTCACHE.DAT" (
    del /f /q "%WinDir%\System32\FNTCACHE.DAT" 2>nul
    if not exist "%WinDir%\System32\FNTCACHE.DAT" (
        echo   [OK] FNTCACHE.DAT deleted.
        set /a "Deleted+=1"
    ) else (
        echo   [FAIL] FNTCACHE.DAT could not be deleted. >&2
        set /a "Failed+=1"
    )
)

echo.
echo   Files deleted: %Deleted%  Failed: %Failed%

:: =============================================
:: Step 3: Restart font cache services
:: =============================================
echo.
echo [3/4] Restarting font cache services...

net start FontCache >nul 2>&1
sc query FontCache 2>nul | findstr /i "RUNNING" >nul 2>&1
if not errorlevel 1 (
    echo   [OK] FontCache started, cache rebuild initiated.
) else (
    echo   [WARNING] FontCache did not start. It may start after a reboot. >&2
)

net start "FontCache3.0.0.0" >nul 2>&1

:: =============================================
:: Step 4: Verify and report
:: =============================================
echo.
echo [4/4] Verification...

:: Check if the service recreated the cache directory
if exist "%CacheDir1%\" (
    echo   [OK] FontCache directory recreated by the service.
) else (
    echo   [INFO] Cache will be rebuilt as applications request fonts.
)

echo.
echo ============================================================

if %Failed% equ 0 (
    echo   [OK] Font cache cleared successfully.
) else (
    echo   [WARNING] Some files could not be deleted (%Failed% failures^).
    echo   A system reboot may be needed to complete the cleanup.
)

echo.
echo   Font rendering should improve after the rebuild.
echo   If issues persist, reboot the computer to fully reset.
echo.
echo ============================================================

:: Log the operation
for /f "delims=" %%t in (
    'powershell -NoProfile -Command "Get-Date -Format ''yyyy-MM-dd HH:mm:ss''"'
) do echo [%%t] FONT CACHE RESET: %Deleted% deleted, %Failed% failed on %COMPUTERNAME% by %USERNAME% >> "%~dp0font_cache_repair.log"

endlocal
exit /b 0

Why three cache locations:

Windows stores font cache data in multiple locations for different purposes:

  1. FontCache\*.dat: The primary runtime cache used by the FontCache service for application font rendering.
  2. FontCache-S-1-5-* directories: Per-user-SID font cache directories used on multi-user systems and Remote Desktop sessions.
  3. FNTCACHE.DAT: The boot-time font cache loaded during Windows startup, before user login. Corruption here can cause font issues system-wide, even at the login screen.

Why the WPF service may not exist:

FontCache3.0.0.0 is the Windows Presentation Foundation (WPF) font cache. It's present on systems with .NET Framework 3.0+ but may be absent on minimal Server Core installations or systems where WPF components were removed. The script handles this gracefully.

Method 2: Font Cache Reset with Application-Level Cleanup

Some applications maintain their own font caches separate from Windows. This method handles the most common application-specific caches.

@echo off
setlocal

echo [INFO] Extended font cache cleanup (system + applications)...
echo.

net session >nul 2>&1
if errorlevel 1 (
    echo [ERROR] Administrator privileges required. >&2
    endlocal
    exit /b 1
)

:: =============================================
:: System font cache (Method 1 logic)
:: =============================================
echo [ACTION] Clearing system font cache...

net stop FontCache >nul 2>&1
net stop "FontCache3.0.0.0" >nul 2>&1
timeout /t 3 /nobreak >nul

:: Delete system caches
del /f /q "%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache\*.*" 2>nul
for /d %%d in ("%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache-*") do (
    del /f /q "%%d\*.*" 2>nul
)
del /f /q "%WinDir%\System32\FNTCACHE.DAT" 2>nul

net start FontCache >nul 2>&1

echo [OK] System font cache cleared.

:: =============================================
:: Adobe font cache (if Adobe CC is installed)
:: =============================================
echo.
echo [ACTION] Checking for Adobe font caches...

set "AdobeFontCache=%LocalAppData%\Adobe\CoreSync\plugins\livetype\r"
if exist "%AdobeFontCache%\" (
    del /f /q "%AdobeFontCache%\*.*" 2>nul
    echo [OK] Adobe font cache cleared.
) else (
    echo [INFO] No Adobe font cache found.
)

:: AdobeFnt*.lst files in common locations
for %%d in (
    "%LocalAppData%\Adobe"
    "%AppData%\Adobe"
    "%ProgramData%\Adobe"
) do (
    if exist "%%~d\" (
        del /f /s /q "%%~d\AdobeFnt*.lst" 2>nul
    )
)

:: =============================================
:: Office font cache
:: =============================================
echo [ACTION] Checking for Office font caches...

set "OfficeFontCache=%LocalAppData%\Microsoft\Office\16.0\FontCache"
if exist "%OfficeFontCache%\" (
    del /f /q "%OfficeFontCache%\*.*" 2>nul
    echo [OK] Office font cache cleared.
) else (
    echo [INFO] No Office font cache found at expected location.
)

echo.
echo [OK] Extended font cache cleanup complete.
echo.
echo [RECOMMENDED] Reboot the computer for a full font reset.
echo Applications may need to rebuild their individual font caches
echo on next launch, which may cause a brief delay.

endlocal
exit /b 0

When application caches matter:

Application Font Cache Location Clearing Method
Adobe CC apps %LocalAppData%\Adobe\CoreSync\ + AdobeFnt*.lst Method 2 or Adobe CC preferences
Microsoft Office %LocalAppData%\Microsoft\Office\16.0\FontCache\ Method 2 or Office repair
Chrome Internal profile cache chrome://settings/clearBrowserData (Cached images)
Firefox Internal profile cache about:support → Clear Startup Cache

Method 3: Verify Font Cache Health

Check the current state of font cache files and the FontCache service without modifying anything.

@echo off
setlocal EnableDelayedExpansion

echo ============================================================
echo   Font Cache Health Check
echo ============================================================
echo.
echo Computer: %COMPUTERNAME%
echo Date:     %date% %time%
echo.
echo ============================================================
echo.

:: ============================================================
:: Check 1: Font Cache Services
:: ============================================================

echo ============================================================
echo   Font Cache Services
echo ============================================================
echo.

set "FontCacheRunning=0"
set "FontCache3Running=0"

:: Check FontCache service
sc query FontCache 2>nul | findstr /i "STATE" >nul 2>&1

if !errorlevel! equ 0 (
    for /f "tokens=4" %%a in ('sc query FontCache 2^>nul ^| findstr "STATE"') do (
        set "FontCacheState=%%a"
    )
    
    echo   FontCache:        !FontCacheState!
    
    if /i "!FontCacheState!"=="RUNNING" set "FontCacheRunning=1"
) else (
    echo   FontCache:        Not installed
    set "FontCacheState=NOT_FOUND"
)

:: Check FontCache 3.0.0.0 service (.NET Framework)
sc query FontCache3.0.0.0 2>nul | findstr /i "STATE" >nul 2>&1

if !errorlevel! equ 0 (
    for /f "tokens=4" %%a in ('sc query FontCache3.0.0.0 2^>nul ^| findstr "STATE"') do (
        set "FontCache3State=%%a"
    )
    
    echo   FontCache3.0.0.0: !FontCache3State!
    
    if /i "!FontCache3State!"=="RUNNING" set "FontCache3Running=1"
) else (
    echo   FontCache3.0.0.0: Not installed (normal if .NET 3.x not present^)
    set "FontCache3State=NOT_FOUND"
)

echo.

:: ============================================================
:: Check 2: Font Cache Files
:: ============================================================

echo ============================================================
echo   Font Cache Files
echo ============================================================
echo.

set "CacheDir=%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache"

if exist "%CacheDir%\" (
    echo   Cache Directory:  !CacheDir!
    echo   Status:           EXISTS
    echo.
    
    :: Count files
    set "CacheCount=0"
    set "CacheTotalSize=0"
    
    for %%f in ("!CacheDir!\*.*") do (
        set /a CacheCount+=1
    )
    
    echo   Cache Files:      !CacheCount! file(s^)
    echo.
    
    :: List cache files with details
    if !CacheCount! gtr 0 (
        echo   Cache File Details:
        for %%f in ("!CacheDir!\*.*") do (
            set "FileSize=%%~zf"
            set "FileDate=%%~tf"
            
            :: Convert bytes to KB
            set /a "FileSizeKB=FileSize/1024"
            
            echo     - %%~nxf
            echo       Size: !FileSizeKB! KB
            echo       Date: !FileDate!
        )
    )
) else (
    echo   Cache Directory:  !CacheDir!
    echo   Status:           NOT FOUND
    echo.
    echo   [INFO] This may indicate font cache needs initialization
)

echo.

:: Check FNTCACHE.DAT
set "FntCacheFile=%WinDir%\System32\FNTCACHE.DAT"

if exist "!FntCacheFile!" (
    echo   FNTCACHE.DAT:     EXISTS
    
    for %%f in ("!FntCacheFile!") do (
        set "FntSize=%%~zf"
        set "FntDate=%%~tf"
        
        set /a "FntSizeKB=FntSize/1024"
        
        echo   Location:         !FntCacheFile!
        echo   Size:             !FntSizeKB! KB (%%~zf bytes^)
        echo   Last Modified:    !FntDate!
    )
) else (
    echo   FNTCACHE.DAT:     NOT FOUND
    echo   Location:         !FntCacheFile!
    echo.
    echo   [WARNING] Main font cache file missing
    echo   [INFO] This may cause slow font rendering
)

echo.

:: ============================================================
:: Check 3: Installed Fonts
:: ============================================================

echo ============================================================
echo   Installed Fonts Inventory
echo ============================================================
echo.

set "FontsDir=%WinDir%\Fonts"

if exist "!FontsDir!\" (
    echo   Fonts Directory:  !FontsDir!
    echo   Status:           EXISTS
    echo.
    
    :: Count font files
    set "FontCount=0"
    for %%f in ("!FontsDir!\*.*") do (
        set /a FontCount+=1
    )
    
    echo   System Fonts:     !FontCount! file(s^)
    echo.
    
    :: Count by type
    set "TtfCount=0"
    set "OtfCount=0"
    set "OtherCount=0"
    
    for %%f in ("!FontsDir!\*.ttf") do set /a TtfCount+=1
    for %%f in ("!FontsDir!\*.otf") do set /a OtfCount+=1
    
    echo   Font Types:
    echo     - TrueType (.ttf):   !TtfCount!
    echo     - OpenType (.otf):   !OtfCount!
    
) else (
    echo   Fonts Directory:  NOT FOUND
    echo   [CRITICAL] System fonts directory missing!
)

echo.

:: ============================================================
:: Check 4: User Fonts
:: ============================================================

echo ============================================================
echo   User-Installed Fonts
echo ============================================================
echo.

set "UserFontsDir=%LOCALAPPDATA%\Microsoft\Windows\Fonts"

if exist "!UserFontsDir!\" (
    echo   User Fonts Dir:   !UserFontsDir!
    echo   Status:           EXISTS
    echo.
    
    set "UserFontCount=0"
    for %%f in ("!UserFontsDir!\*.*") do set /a UserFontCount+=1
    
    echo   User Fonts:       !UserFontCount! file(s^)
) else (
    echo   User Fonts Dir:   No user-specific fonts installed
)

echo.

:: ============================================================
:: Health Assessment
:: ============================================================

echo ============================================================
echo   Health Assessment
echo ============================================================
echo.

set "HealthScore=0"
set "MaxScore=3"
set "Issues="

:: Check 1: FontCache service running
if !FontCacheRunning! equ 1 (
    echo   [OK] FontCache service:    Running
    set /a HealthScore+=1
) else (
    echo   [KO] FontCache service:    Not running
    set "Issues=!Issues! FontCacheService"
)

:: Check 2: Cache directory exists
if exist "!CacheDir!\" (
    echo   [OK] Cache directory:      Exists
    set /a HealthScore+=1
) else (
    echo   [KO] Cache directory:      Missing
    set "Issues=!Issues! CacheDirectory"
)

:: Check 3: FNTCACHE.DAT exists
if exist "!FntCacheFile!" (
    echo   [OK] FNTCACHE.DAT:         Exists
    set /a HealthScore+=1
) else (
    echo   [KO] FNTCACHE.DAT:         Missing
    set "Issues=!Issues! FntCacheFile"
)

echo.
echo   Health Score:         !HealthScore! / !MaxScore!
echo.

:: Overall assessment
if !HealthScore! equ !MaxScore! (
    echo ============================================================
    echo   Status: HEALTHY
    echo ============================================================
    echo.
    echo   Font cache appears to be functioning normally.
    echo.
    set "ExitCode=0"
    
) else if !HealthScore! geq 2 (
    echo ============================================================
    echo   Status: MINOR ISSUES
    echo ============================================================
    echo.
    echo   Font cache has minor issues but may be functional.
    echo.
    echo   Issues detected: !Issues!
    echo.
    echo   Recommendation:
    echo     - Restart FontCache service
    echo     - Rebuild font cache if problems persist
    echo.
    set "ExitCode=1"
    
) else (
    echo ============================================================
    echo   Status: UNHEALTHY
    echo ============================================================
    echo.
    echo   Font cache has significant problems.
    echo.
    echo   Issues detected: !Issues!
    echo.
    echo   Recommended Actions:
    echo     1. Stop FontCache service:
    echo        net stop FontCache
    echo.
    echo     2. Delete cache files:
    echo        del /q "!CacheDir!\*.*"
    echo        del "!FntCacheFile!"
    echo.
    echo     3. Restart FontCache service:
    echo        net start FontCache
    echo.
    echo     4. Reboot if issues persist
    echo.
    set "ExitCode=2"
)

echo ============================================================
echo.

pause
endlocal
exit /b !ExitCode!

How to Avoid Common Errors

Wrong Way: Deleting Cache Files Without Stopping Services

:: FAILS: FontCache service has file locks on the .dat files
del /f /q %WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache\*.dat
:: Result: "Access is denied" or "The process cannot access the file"

Correct Way: Stop FontCache and FontCache3.0.0.0 before deleting. Method 1 stops both services and verifies they actually stopped.

Wrong Way: Stopping Only the Primary FontCache Service

:: INCOMPLETE: WPF applications may still have corrupt cached fonts
net stop FontCache
:: (miss FontCache3.0.0.0)

WPF applications (.NET/XAML apps, some modern Windows UI components) use FontCache3.0.0.0. If only the primary FontCache is stopped, WPF-rendered text may still show corruption.

Correct Way: Stop both FontCache and FontCache3.0.0.0 (Method 1).

Wrong Way: Forgetting FNTCACHE.DAT

:: INCOMPLETE: boot-time font cache is still corrupt
del /f /q %WinDir%\ServiceProfiles\...\FontCache\*.dat
:: FNTCACHE.DAT in System32 is not cleared

FNTCACHE.DAT is the boot-time font cache loaded before user login. If only the runtime cache is cleared, font issues may persist at the login screen and in early-starting applications.

Correct Way: Delete both the FontCache\*.dat files AND FNTCACHE.DAT (Method 1).

Problem: Font Cache Service Won't Stop

If an application (browser, design tool, office suite) is actively rendering text, it may hold references that prevent the FontCache service from stopping.

Solution: Close all applications before running the script. If the service still won't stop:

:: Force-stop the service process
taskkill /f /fi "services eq FontCache" >nul 2>&1
timeout /t 3 /nobreak >nul

Problem: Font Issues Persist After Cache Reset

If clearing the cache doesn't fix the rendering:

  1. Reboot: Some font data is cached in memory by applications.
  2. Check for corrupt font files: A damaged .ttf or .otf file in C:\Windows\Fonts will re-corrupt the cache when it's rebuilt. Test by temporarily removing recently installed fonts.
  3. Check for duplicate fonts: Two versions of the same font (e.g., Calibri from Office 2016 and Calibri from Office 2021) can cause rendering conflicts.
  4. Run SFC: System file corruption may have damaged the font rendering subsystem.
  5. Check application-specific caches: Use Method 2 to clear Adobe, Office, and browser font caches.

Best Practices and Rules

1. Stop BOTH Font Cache Services

Always stop FontCache AND FontCache3.0.0.0 before deleting cache files. Missing either one leaves part of the cache locked.

2. Delete from ALL Cache Locations

Clear the FontCache\*.dat directory, FontCache-* per-user directories, AND FNTCACHE.DAT. Clearing only one location may leave corrupt data in another.

3. Reboot After Clearing

While the script restarts the FontCache service, applications that had font data in memory need a restart. A full system reboot is the most thorough way to ensure all font rendering starts fresh.

4. Check for Font File Issues If Cache Corruption Recurs

If the font cache corrupts repeatedly, the cause is likely a damaged or conflicting font file, not the cache itself. The cache will re-corrupt every time it rebuilds from a broken source font.

5. Close Applications Before Running

Open applications hold references to font cache data through the FontCache service. Close all applications (especially browsers, Office, and design tools) before running the cache reset.

6. Log the Operation

Track font cache resets for pattern detection, if the same machine needs frequent resets, investigate the root cause (corrupt font file, disk errors, conflicting software).

Conclusion

Resetting the font cache resolves the most common text rendering glitches in Windows, garbled characters, wrong typefaces, missing glyphs, and squared symbols. By properly managing both font cache services, deleting cache files from all three storage locations, handling application-specific caches, and verifying service restart, you create a thorough repair that forces Windows to rebuild its font index from the original font files. For recurring font issues, investigate the font files themselves rather than repeatedly clearing the cache.

Navigation