Thursday, June 28, 2012

Silent installation of TrueType fonts on Windows 7 (32 and 64bit)

The easiest way I have found so far to silently install TrueType fonts (*.TTF) is by using FontReg from Kai Liu.

The setup procedure is quite simple. First, create a folder where you put all *.TTF files in you want to install.

Next download FontReg and extract the contents of the 7Zip archive. Copy bin.x86-32\FontReg.exe to newly created folder and rename it to FontReg_x32.exe. Do the same with bin.x86-64\FontReg.exe and name the file FontReg_x64.exe.

Then add the following batch file and name it Install_Fonts.bat:


Rem -------------------------------------------------------------------
Rem ----- 32 / 64-bit Font Installation Starter by TeX HeX -
http://www.texhex.info/
if defined ProgramFiles(x86) GOTO WinX64

Rem This seems to be a 32-bit machine
SET IsX64=0
GOTO Exec

:WinX64
SET IsX64=1
GOTO Exec

:Exec
echo "IsX64" (is x64 Windows): %IsX64%
Rem "0" on x32 - 1 on x64
Rem -------------------------------------------------------------------
Rem Change to drive and path where we are running from
%~d0
cd "%~dp0"

SET COMMAND_NAME=XXXX

IF "%IsX64%"=="1" SET COMMAND_NAME=%~dp0FontReg_x64.exe
IF "%IsX64%"=="0" SET COMMAND_NAME=%~dp0FontReg_x32.exe

echo %COMMAND_NAME%

"%COMMAND_NAME%" /copy
exit %ERRORLEVEL%

Once this is all done, the folder should look similar to this:

font_inst

No instruct your deployment tool to copy this folder locally and start install_fonts.bat.

Normally the new fonts will appear without restart but some machines (I still haven’t figured out why) will require an restart before they show the new fonts.

Enjoy!

2 comments:

  1. better:
    IF "%IsX64%"=="1 " SET COMMAND_NAME=%~dp0FontReg_x64.exe
    IF "%IsX64%"=="0 " SET COMMAND_NAME=%~dp0FontReg_x32.exe

    ReplyDelete