Skip to content

Instantly share code, notes, and snippets.

@brainplot
Last active September 12, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brainplot/19816ff07a0c31efee005d34271650e3 to your computer and use it in GitHub Desktop.
Save brainplot/19816ff07a0c31efee005d34271650e3 to your computer and use it in GitHub Desktop.
Rebuild font cache in Windows and reboot your computer in order to solve some font rendering issues
:: 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment