Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add windows fonts by command line
REM http://www.msfn.org/board/topic/119612-how-to-install-a-font-via-the-command-line/
@ECHO OFF
TITLE Adding Fonts..
REM Filename: ADD_Fonts.cmd
REM Script to ADD TrueType and OpenType Fonts for Windows
REM By Islam Adel
REM 2012-01-16
REM How to use:
REM Place the batch file inside the folder of the font files OR:
REM Optional Add source folder as parameter with ending backslash and dont use quotes, spaces are allowed
REM example "ADD_fonts.cmd" C:\Folder 1\Folder 2\
IF NOT "%*"=="" SET SRC=%*
ECHO.
ECHO Adding Fonts..
ECHO.
FOR /F %%i in ('dir /b "%SRC%*.*tf"') DO CALL :FONT %%i
REM OPTIONAL REBOOT
REM shutdown -r -f -t 10 -c "Reboot required for Fonts installation"
ECHO.
ECHO Done!
PAUSE
EXIT
:FONT
ECHO.
REM ECHO FILE=%~f1
SET FFILE=%~n1%~x1
SET FNAME=%~n1
SET FNAME=%FNAME:-= %
IF "%~x1"==".otf" SET FTYPE=(OpenType)
IF "%~x1"==".ttf" SET FTYPE=(TrueType)
ECHO FILE=%FFILE%
ECHO NAME=%FNAME%
ECHO TYPE=%FTYPE%
COPY /Y "%SRC%%~n1%~x1" "%SystemRoot%\Fonts\"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "%FNAME% %FTYPE%" /t REG_SZ /d "%FFILE%" /f
GOTO :EOF
@ryanlintott

This comment has been minimized.

Copy link

@ryanlintott ryanlintott commented Jul 3, 2013

Great script! The only problem is that it doesn't work for font files with spaces in them. I have altered line 19 to fix it.

FOR /F "tokens=" %%i in ('dir /b "%SRC%.*tf"') DO CALL :FONT "%%i"

Seems to work well. Still doesn't work with characters such as "&" but I've just renamed those files as a workaround.

@selcukdere

This comment has been minimized.

Copy link

@selcukdere selcukdere commented Oct 4, 2016

I spent a lot of time to find a way for installing font without restart. Finally I found this ClickFont. It's an easy and exact solution :)

Link: http://www.softpedia.com/get/Others/Font-Utils/Clickfont.shtml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.