Installing fonts via command line/script

Page 1 of 2 12 LastLast

  1. Posts : 1
    Windows 7
       #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 Computer


  2. Posts : 1
    windows 7
       #2

    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 Computer


  3. Posts : 1
    Win7 and XP
       #3

    Anyway to do this all within an existing batch file? Without launching a VB application?
      My Computer


  4. Posts : 3
    windows 7 ultimate
       #4

    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 Computer


  5. Posts : 5,056
    Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86
       #5

    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 Computer


  6. Posts : 3
    windows 7 ultimate
       #6

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

    Thanks anyway
      My Computer


  7. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #7

    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 Computer


  8. Posts : 3
    windows 7 ultimate
       #8

    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 Computer


  9. Posts : 1
    Windows XP 32-bit
       #9

    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 Computer


  10. Posts : 1
    Windows 7 Ultimate x64
       #10

    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 Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 04:50.
Find Us