Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Installing fonts via command line/script

10 Apr 2015   #11
ElMonoAlado

Windows 7 ultimate 64
 
 

Quote   Quote: Originally Posted by takeitback86 View Post
The best way to do this is to create a vbs script and run it from a command line. So open notepad and paste:
Code:
Const FONTS = &H14& 
 
 Set objShell = CreateObject("Shell.Application") 
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "C:\Scripts\Myfont.ttf"
Just change C:\Scripts\Myfont.ttff to the current location of ttf file you want to install and that's the only thing you should have to replace, go to file and save as and make sure you save it as a .vbs file. Then just save the vbs script where ever you like and run the script via cmd or batch file. If you need multiple fonts installed just repeat the objFolder.CopyHere "C:\Scripts\Myfont.ttf" line at the end with each font name in the appropriate place.

I should also mention that the batch file or command should look like this:
Code:
cscript "C:\folder\InstallFont.vbs"
I've tried the first few answers on this forum to no avail and this is the only thing that has worked for me so I thought I'd share.


reference: Hey, Scripting Guy! How Can I Install Fonts Using a Script? - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs
I had the same problem and your way worked for me perfectly! many thanks!


My System SpecsSystem Spec
.
10 Apr 2015   #12
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

The TechNet article mentions that simply copying a font file to the Fonts folder will not work.
Quote:
As far as we know, the only programmatic way to get Windows to recognize that a new font has been added to the Fonts folder, and thus get Windows to install that font for you, is to use the Shell object.
Which explains why all the batch files (so far) in this thread don't work (well).


InstallFont.vbs
Code:
strFontToInstall = "C:\PathTo\Some\Font.fon"
Const FONTS = &H14

Set objShell = CreateObject("Shell.Application") 
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere strFontToInstall
InstallFont(golfed).vbs
Code:
strFontToInstall = "C:\PathTo\Some\Font.fon"
CreateObject("Shell.Application").Namespace(20).CopyHere strFontToInstall

InstallFont.bat
Code:
set font_to_install="C:\PathTo\Some\Font.fon"
(
	echo Set objShell = CreateObject^("Shell.Application"^)
	echo Set objFolder = objShell.Namespace^(20^)
	echo objFolder.CopyHere "%FONT_TO_INSTALL:"=%"
) > "%TEMP%\tmp_%~n0.vbs"
WScript "%TEMP%\tmp_%~n0.vbs"
del "%TEMP%\tmp_%~n0.vbs"
InstallFont(golfed).bat
Code:
set font_to_install="C:\PathTo\Some\Font.fon"
echo CreateObject^("Shell.Application"^).Namespace(20).CopyHere "%FONT_TO_INSTALL:"=%">"%TEMP%\tmp_InstallFont.vbs"&&(WScript "%TEMP%\tmp_InstallFont.vbs"&timeout 1 >NUL&del "%TEMP%\tmp_InstallFont.vbs")

Quote   Quote: Originally Posted by jerrym View Post
Does anyone know an effective command line to use to place a font into the font folder in Windows 7?
To install a font? Here's your command... (good luck remembering it though)

Command Line command
Code:
echo CreateObject^("Shell.Application"^).Namespace(20).CopyHere "<PathToFontFile>">"%TEMP%\tmp_InstallFont.vbs"&&(WScript "%TEMP%\tmp_InstallFont.vbs"&timeout 1 >NUL&del "%TEMP%\tmp_InstallFont.vbs")

And for anyone looking, here's a simple font installer batch file.
Code:
@echo off

REM Drop a font file on me and I'll install it!

set default_font_to_install="C:\PathTo\Some\Font.fon"
if "%~1"=="" ( set font_to_install=%DEFAULT_FONT_TO_INSTALL%) else (
	set font_to_install=%1
)
(
	echo Set objShell = CreateObject^("Shell.Application"^)
	echo Set objFolder = objShell.Namespace^(20^)
	echo objFolder.CopyHere "%FONT_TO_INSTALL:"=%"
) > "%TEMP%\tmp_%~n0.vbs"
WScript "%TEMP%\tmp_%~n0.vbs"
del "%TEMP%\tmp_%~n0.vbs"

(Note: All batch files above use temp files)
My System SpecsSystem Spec
30 Oct 2015   #13
digitaltomj

Windows 7 Home Premium x64
 
 

I was able to do this from a network shared folder on our domain for a bunch of fonts using the following batch script. It will copy fonts from a directory into C:\Windows\Fonts\ and then add a registry key for each font.

Code:
copy /Y "location_of_folder_with_fonts\*.ttf" "C:\Windows\Fonts\"
regedit /s "location_of_folder_with_font.reg\font.reg"
pause
The font.reg file looks like this:
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Font_Name#1 (TrueType)"="File_Name#1.ttf"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Font_Name#2 (TrueType)"="File_Name#2.ttf"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Font_Name#2 (TrueType)"="File_Name#3.ttf"
Just edit the parts in bold as needed. When this script is ran as admin it works fine and after a reboot, the fonts can be seen in the fonts folder from the control panel.
My System SpecsSystem Spec
.

30 Oct 2015   #14
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by digitaltomj View Post
When this script is ran as admin it works fine and after a reboot [...]
Those are the differences between it and the VBScript solution: the registry solution requires administrative privileges, and also a reboot.
My System SpecsSystem Spec
12 Nov 2015   #15
mejsu

New York
 
 
.VBS to automatically overwrite existing fonts?

Thanks takeitback86! This works like a charm but got a question for you.

If computers have fonts already installed, they will get a Windows notification popup on startup asking if the fonts need to get replaced. Would you know if there is a way to do this automatically (a line of code). I would like the .vbs to overwrite the existing fonts without having user to manually click on YES button for all font notification pop ups?
My System SpecsSystem Spec
04 Oct 2016   #16
susemania

Windows 7 Ultimate x64
 
 

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: ClickFont Download
My System SpecsSystem Spec
Reply

 Installing fonts via command line/script




Thread Tools




Similar help and support threads
Thread Forum
Command Line - Help
Hi Guy's and Girls, Just first off I've never been too good with CMD and only an Apprentice in my company I work for. Now something I've wanted to do for awhile was to make the following but I don't necassirealy I know how to do this in one batch file: I would need a Batch file that is...
General Discussion
What is wrong with this command line?
Help please I am pulling my hair out. I use a desktop shortcut to run an application called get_iplayer.cmd located in the directory c:\program files\get_iplayer The line in the Target of the shortcut properties therefore reads: C:\Windows\System32\cmd.exe /k "c:\program...
General Discussion
Web Browser fonts changed after installing new fonts to computer
Recently I installed two fonts onto computer for Typography, and upon doing so the fonts changed on Google Chrome and Firefox to this bold font. It appears to be the default font as before, just in bold now. I've tried checking the browsers font settings, and they're at the settings they were...
Browsers & Mail
How can I set this via command-line or registry?
How can I set this via command-line or registry? I need a way to automatically launch "Explorer c:\folder\myfolder" with a view appropriate for long filenames on any Windows Vista/Win7 PC.
Customization
Gpedit via command line
how can I enable disable a policy using gpedit! Not via the GUI, you go do some clicks and enable. But I want to execute one shot command which will say disable AutoRun. I have searched exenstively, no results. I kind need this for my automation stuff. Thanks, Akshay
Performance & Maintenance
Command Line
Is there a cmd.exe /switch for “run as administrator” ? Thanks-
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 23:48.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App