Skip to content

Instantly share code, notes, and snippets.

@brainplot
Last active September 12, 2023 11:39

Revisions

  1. brainplot revised this gist Aug 17, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rebuild_font_cache.bat
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ echo This script is going to restart your computer.
    echo Make sure to close all open applications in order not to lose any unsaved work.
    choice /m "Do you want to continue"

    if %ERRORLEVEL% NEQ "1" GOTO End
    if %errorlevel% NEQ "1" goto End

    :: Stop and disable "Windows Font Cache Service" service
    :FontCache
  2. brainplot created this gist Aug 17, 2020.
    29 changes: 29 additions & 0 deletions rebuild_font_cache.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    :: This script should be run in a priviledged command prompt

    @echo off

    echo This script is going to restart your computer.
    echo Make sure to close all open applications in order not to lose any unsaved work.
    choice /m "Do you want to continue"

    if %ERRORLEVEL% NEQ "1" GOTO End

    :: Stop and disable "Windows Font Cache Service" service
    :FontCache
    sc stop "FontCache"
    sc config "FontCache" start=disabled
    sc query FontCache | findstr /I /C:"STOPPED"
    if not %errorlevel%==0 (goto FontCache)

    :: Grant access rights to current user for "%WinDir%\ServiceProfiles\LocalService" folder and contents
    icacls "%WinDir%\ServiceProfiles\LocalService" /grant "%UserName%":F /C /T /Q

    :: Delete font cache
    del /A /F /Q "%WinDir%\ServiceProfiles\LocalService\AppData\Local\FontCache\*FontCache*"
    del /A /F /Q "%WinDir%\System32\FNTCACHE.DAT"

    :: Enable and start "Windows Font Cache Service" service
    sc config "FontCache" start=auto
    sc start "FontCache"

    :End