Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows: install fonts from cmd/.bat file

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

as i understand it, it requires moving the text file to the correct folder and then also creating a registry value i think? but I havent been able to find one that is confirmed working.

a note: I am using windows 8 so that might make a difference.

another note: what I am trying to do is batch install fonts that I ripped from MKV files. (so this will be a function that is part of a larger .bat file, i can post the code if needed)

like image 662
begna112 Avatar asked Oct 18 '12 02:10

begna112


People also ask

How do I install a TTF File on Windows?

To install the TrueType font in Windows:Click on Start, Select, Settings and click on Control Panel. Click on Fonts, click on File in the main tool bar and select Install New Font. Select the folder where the font is located. The fonts will appear; select the desired font that is titled TrueType and click on OK.


2 Answers

maybe this is needed too:

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "FontName (TrueType)" /t REG_SZ /d FontName.ttf /f
like image 74
T.Todua Avatar answered Sep 23 '22 06:09

T.Todua


You'll need to use a PowerShell or VB script. They basically re-use the shell components that do the same thing in Windows Explorer, and they don't need a reboot.

See here for a PowerShell script that installs all fonts from a directory for Windows 8.1 or earlier: https://social.technet.microsoft.com/Forums/fr-FR/winserverpowershell/thread/fcc98ba5-6ce4-466b-a927-bb2cc3851b59

Here is a similar script for Windows 10 (Windows Server 2019) that also updates the Windows Registry: https://social.technet.microsoft.com/Forums/en-US/0c94dcf5-b89d-42e5-a499-06313f46f88b/can-no-longer-install-fonts-via-script-in-windows-10-1809?forum=win10itprogeneral

Also, you'll need to run the script in admin mode. So if the PowerShell script is InstallFonts.ps1, your batch file needs to look like:

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

Any powershell errors will appear in 'err.out' on the same folder as the script.

like image 28
Yoshi Avatar answered Sep 23 '22 06:09

Yoshi