Subscribe to Windows IT Pro
March 05, 1999 12:00 AM

How can I install a font from the command line/batch file?

Windows IT Pro
InstantDoc ID #15167
Rating: (24)

A. When you install a font all it does is copy the .ttf file to the %systemroot%\fonts and add an entry in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts. This can be automated with a batch file as follows

Rem fontinst.bat
copy akbar.ttf %systemroot%\fonts
regedit /s font.reg

The font.reg would contain the following:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Akbar Plain (TrueType)"="akbar.ttf"

In this example it copies akbar.ttf which is called "Akbar Plain (TrueType)" (yes its the Simpsons font ;-) ). The reg scipt actually creates a value called "Akbar Plain (TrueType)" under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts with its contents "akbar.ttf". The new font would be visable once the machine has been rebooted.

If you have some older 16bit applications you may want to add the font to win.ini as well in the [fonts] section. This could be accomplished using a .inf file, e.g.

[UpdateInis]
"E:\WINNT\WIN.INI","Fonts",,"Akbar Plain (TrueType)=akbar.ttf"


Related Content:

ARTICLE TOOLS

Comments
  • Islam Adel
    4 months ago
    Jan 16, 2012

    @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=%*
    REM COPY /Y "%SRC%Charter-Bold.ttf" "%SystemRoot%\\Fonts\\"
    REM reg add "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" /v "Charter Bold (TrueType)" /t REG_SZ /d "Charter-Bold.ttf" /f
    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

  • gbraate@smud.org
    3 years ago
    Oct 08, 2009

    Super sweet. I told my work associates that this could be done.

  • Anonymous User
    7 years ago
    Aug 08, 2005

    What about Open Type font?

  • Christian
    9 years ago
    Oct 28, 2003

    Beware of Type1-fonts, for these belong in [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\Type 1 Fonts]

  • Mars
    9 years ago
    Oct 09, 2003

    When I install new font this way, it is not in list of fonts in notepad nor office applications :( Do you know any solution for this please?

    Thanks
    MarS

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.