Windows: installing fonts from cmd / .bat file

Does anyone know how to install font files (.ttf, .TTF, .otf, .otf, etc.) through the command line on windows?

as I understand it, you need to move the text file to the desired folder, and then create a registry value that I think? but I could not find the one that is confirmed.

Note: I use windows 8 so that it can make a difference.

One more note: I'm trying to do this with batch fonts that I ripped from MKV files. (so this will be a function that is part of a larger .bat file, I can send the code if necessary)

+4
source share
5 answers

You will need to use PowerShell or VB script. They mainly reuse shell components that do the same in Windows Explorer and do not need a reboot.

See here the PowerShell script that installs all the fonts from the directory: http://social.technet.microsoft.com/Forums/fr-FR/winserverpowershell/thread/fcc98ba5-6ce4-466b-a927-bb2cc3851b59

In addition, you need to run the script in administrator mode. Therefore, if the PowerShell script is InstallFonts.ps1, your batch file should look like this:

powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out powershell .\InstallFonts.ps1 2>> err.out 

Any command line errors will appear in 'err.out' in the same folder as the script.

+5
source

Did you try to copy them to the font folder?

 copy font.ttf %windir%\Fonts 
+1
source

Perhaps this is also necessary:

 reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "FontName (TrueType)" /t REG_SZ /d FontName.ttf /f 
+1
source

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

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

font.reg will contain the following:

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

Source: m.windowsitpro.com

0
source

An example batch file, it works in the current directory.

  IF "%*" NEQ "" SET FONT=%* ( FOR /F %%i in ('dir /b "%FONT%*.*tf"') DO CALL :DEST %%i ) else ( EXIT ) :DEST SET FONTFILE=%~n1%~x1 SET FONTNAME=%~n1 IF "%~x1"==".ttf" SET FONTTYPE=TrueType IF "%~x1"==".otf" SET FONTTYPE=OpenType ECHO FILE = %FONTFILE% ECHO NAME = %FONTNAME:-= % ECHO TYPE = %FONTTYPE% fontview %~dp0%FONTFILE% GOTO :EXIT 
0
source

Source: https://habr.com/ru/post/1440437/


All Articles