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


12 Oct 2009   #1

 
 
Installing fonts via command line/script

Windows 7 has apparently changed the way fonts are installed. I have a web page that I use that when visiting the page it looks to see if a file called barcode.exe is installed in a particular folder and if it is not present it downloads the file and executes it. The exe file is designed to place 2 carolina bar code fonts into C:\windows\fonts. This works with no issues in both Windows XP and Windows Vista but is not working in Windows 7. I can manually install these into Windows 7 font folder with no problem, but need to be able to do it automatically. Does anyone know an effective command line to use to place a font into the font folder in Windows 7? Thanks...

Jerry Mill

My System SpecsSystem Spec
.

13 Jan 2010   #2

windows 7
 
 

in my my .bat file, I run Font.vbs file.

rem Add files

O:\BDARevit\Distra\Font.vbs

Text code inside of Font.vbs file as follows:

' Fonts.cfg
' January 13, 2010
' ----------------------------------------------------------
Option Explicit

Dim objShell, objFolder

Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "O:\BDARevit\Distra\architxt.ttf"

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "O:\BDARevit\Distra\BlankSerif.ttf"

Wscript.Quit
My System SpecsSystem Spec
03 Mar 2010   #3

Win7 and XP
 
 

Anyway to do this all within an existing batch file? Without launching a VB application?
My System SpecsSystem Spec
.


11 May 2010   #4

windows 7 ultimate
 
 

This doesn't work for me in windows 7 professional from a windows server 2003.

It works like I have no permission to write in that folder (like if I run a batch file).

There is some non-standard option that I have to enable?

Thank you
My System SpecsSystem Spec
11 May 2010   #5

Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
 
 

When you install a font, all that you actually do is to copy the concerned .ttf file to the %systemroot%\fonts (in most cases that would simply be C:\windows\fonts) and add an entry in under the registry key
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts".

You can do this with a batch file as follows:

Rem fontinstall.bat
xcopy *.ttf %systemroot%\fonts
regedit /s font.reg

The font.reg would contain the following:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"fontname (TrueType)"="filename.ttf"

You would need to reboot to see the font.
My System SpecsSystem Spec
14 May 2010   #6

windows 7 ultimate
 
 

Not in windows 7!
You cannot access the font directory!
This is the problem!

Thanks anyway
My System SpecsSystem Spec
14 May 2010   #7

Windows 8.1 Pro RTM x64
 
 

Here's a batch file that should accomplish what you wish to achieve. Please note that, since you are accessing the HKLM branch of the registry, this MUST be run either from within an administrative account or from one that has been elevated to administrative privileges.

Code:
@ECHO OFF
XCOPY <Source>.<ext> %systemroot%\fonts
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "<Fontname> (<Type>)" /t REG_SZ /d "<Filename>.<ext>" /f
You will need to provide the information in <red>.
My System SpecsSystem Spec
17 May 2010   #8

windows 7 ultimate
 
 

Thanks for the answers.

I put my frizquadratatt.ttf in the c:\ directory, then I create font.cmd

Code:
 
XCOPY c:\frizquadratatt.ttf %systemroot%\fonts
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "Fritz Quadrata TT (True Type)" /t REG_SZ /d "frizquadratatt.ttf" /f
then I launch font.cmd from my desktop clicking "run as administrator"

it works fine...but I still haven't the font installed!!

ok, ok I have to restart the pc (WHY ?!?!? If you can doubleclick on a .ttf file, say install and you are immediatly able to use it!?!? ther must be another way!!)

Now I put this script in my logon.cmd in the domain server and tell the active directory to run it...but it doesn't work!!

Thank again
My System SpecsSystem Spec
17 Jan 2012   #9

Windows XP 32-bit
 
 
How to install a font via the command line? ADD_Fonts.cmd

Here is a batch script to install Fonts in any Folder automatically.
Paste the following code in notepad and save it as "ADD_Fonts.cmd"
place the cmd file inside the folder of the fonts you want to install and run it or
add the source folder as a parameter. for example "ADD_fonts.cmd" C:\Folder 1\Folder 2\

it will install all the fonts automatically by copying them to the Windows Fonts Folder and creating the required Registry values for them

Code:
@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
My System SpecsSystem Spec
04 Mar 2014   #10

Windows 7 Ultimate x64
 
 

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

 Installing fonts via command line/script




Thread Tools



Similar help and support threads for2: Installing fonts via command line/script
Thread Forum
UAC bug with runas from command line? General Discussion
How to get post script name of type 1 fonts? General Discussion
How can I set this via command-line or registry? Customization
libraries and the command line Performance & Maintenance
How to run a command line utility? General Discussion
Command Line General Discussion
Can you boot from the command line? Chillout Room

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 03:24 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33